| 1 |
from Tkinter import * |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
class Test(Frame): |
| 6 |
def printhi(self): |
| 7 |
print "hi" |
| 8 |
|
| 9 |
def createWidgets(self): |
| 10 |
self.QUIT = Button(self, text='QUIT', foreground='red', |
| 11 |
command=self.quit) |
| 12 |
self.QUIT.pack(side=BOTTOM, fill=BOTH) |
| 13 |
|
| 14 |
self.draw = Canvas(self, width="5i", height="5i") |
| 15 |
|
| 16 |
self.button = Button(self, text="this is a button", |
| 17 |
command=self.printhi) |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
self.draw.create_window(300, 300, window=self.button) |
| 26 |
|
| 27 |
self.draw.pack(side=LEFT) |
| 28 |
|
| 29 |
def __init__(self, master=None): |
| 30 |
Frame.__init__(self, master) |
| 31 |
Pack.config(self) |
| 32 |
self.createWidgets() |
| 33 |
|
| 34 |
test = Test() |
| 35 |
|
| 36 |
test.mainloop() |