Guido van Rossum | 35820f7 | 1994-10-07 09:55:26 +0000 | [diff] [blame] | 1 | from Tkinter import * |
| 2 | |
| 3 | |
| 4 | class Test(Frame): |
| 5 | def printit(self): |
| 6 | print self.hi_there["command"] |
| 7 | |
| 8 | def createWidgets(self): |
| 9 | # a hello button |
| 10 | self.QUIT = Button(self, {'text': 'QUIT', |
| 11 | 'fg': 'red', |
| 12 | 'command': self.quit}) |
| 13 | |
| 14 | self.QUIT.pack({'side': 'left', 'fill': 'both'}) |
| 15 | |
| 16 | |
| 17 | self.hi_there = Button(self, {'text': 'Hello', |
| 18 | 'command' : self.printit}) |
| 19 | self.hi_there.pack({'side': 'left'}) |
| 20 | |
| 21 | # note how Packer defaults to {'side': 'top'} |
| 22 | |
| 23 | self.guy2 = Button(self, {'text': 'button 2'}) |
| 24 | self.guy2.pack() |
| 25 | |
| 26 | self.guy3 = Button(self, {'text': 'button 3'}) |
| 27 | self.guy3.pack() |
| 28 | |
| 29 | def __init__(self, master=None): |
| 30 | Frame.__init__(self, master) |
| 31 | Pack.config(self) |
| 32 | self.createWidgets() |
| 33 | |
| 34 | test = Test() |
| 35 | test.mainloop() |