File: class/Workbook/Examples/Lecture11/hello.py
#!/usr/local/bin/python
from Tkinter import * # get widgets
class Hello(Frame): # container subclass
def __init__(self, parent=None):
Frame.__init__(self, parent) # superclass init
self.pack()
self.make_widgets() # attach to self
def make_widgets(self):
widget = Button(self, text='Hello',
command=self.onPress)
widget.pack(side=LEFT)
def onPress(self):
print 'Hi.' # write to stdout
if __name__ == '__main__': Hello().mainloop()