Guido van Rossum | 35820f7 | 1994-10-07 09:55:26 +0000 | [diff] [blame] | 1 | from Tkinter import * |
| 2 | |
| 3 | # this program creates a canvas and puts a single polygon on the canvas |
| 4 | |
| 5 | class Test(Frame): |
| 6 | def printit(self): |
| 7 | print "hi" |
| 8 | |
| 9 | def createWidgets(self): |
| 10 | self.QUIT = Button(self, {'text': 'QUIT', |
| 11 | 'fg': 'red', |
| 12 | 'command': self.quit}) |
| 13 | self.QUIT.pack({'side': 'bottom', 'fill': 'both'}) |
| 14 | |
| 15 | self.draw = Canvas(self, {"width" : "5i", "height" : "5i"}) |
| 16 | |
| 17 | # see the other demos for other ways of specifying coords for a polygon |
| 18 | self.draw.create_polygon("0i", "0i", "3i", "0i", "3i", "3i", "0i" , "3i") |
| 19 | |
| 20 | self.draw.pack({'side': 'left'}) |
| 21 | |
| 22 | |
| 23 | def __init__(self, master=None): |
| 24 | Frame.__init__(self, master) |
| 25 | Pack.config(self) |
| 26 | self.createWidgets() |
| 27 | |
| 28 | test = Test() |
| 29 | |
| 30 | test.mainloop() |