""" tkControl.py add a command and button to tk form """ import Tkinter class App(object): def __init__(self, master): self.frame = Tkinter.Frame(master) self.frame.grid() self.lblOutput = Tkinter.Label(self.frame, text = "Click the button") self.lblOutput.grid() self.txtInput = Tkinter.Entry(self.frame) self.txtInput.grid() self.btnClickMe = Tkinter.Button(self.frame, text = "click me", command = self.sayHi) self.btnClickMe.grid() def sayHi(self): user = self.txtInput.get() text = "Hi there, %s" % user self.lblOutput["text"] = text root = Tkinter.Tk() root.title("control demo") app = App(root) root.mainloop()