Guido van Rossum | 35820f7 | 1994-10-07 09:55:26 +0000 | [diff] [blame] | 1 | from Tkinter import * |
| 2 | |
| 3 | # note that there is no explicit call to start Tk. |
| 4 | # Tkinter is smart enough to start the system if it's not already going. |
| 5 | |
| 6 | class Test(Frame): |
| 7 | def printit(self): |
| 8 | print "hi" |
| 9 | |
| 10 | def createWidgets(self): |
| 11 | self.QUIT = Button(self, {'text': 'QUIT', |
| 12 | 'fg': 'red', |
| 13 | 'command': self.quit}) |
| 14 | |
| 15 | self.QUIT.pack({'side': 'left', 'fill': 'both'}) |
| 16 | |
| 17 | |
| 18 | # a hello button |
| 19 | self.hi_there = Button(self, {'text': 'Hello', |
| 20 | 'command' : self.printit}) |
| 21 | self.hi_there.pack({'side': 'left'}) |
| 22 | |
| 23 | |
| 24 | def __init__(self, master=None): |
| 25 | Frame.__init__(self, master) |
| 26 | Pack.config(self) |
| 27 | self.createWidgets() |
| 28 | |
| 29 | test = Test() |
| 30 | test.mainloop() |