| 1 | from Tkinter import *
|
|---|
| 2 |
|
|---|
| 3 | # this is the same as simple-demo-1.py, but uses
|
|---|
| 4 | # subclassing.
|
|---|
| 5 | # note that there is no explicit call to start Tk.
|
|---|
| 6 | # Tkinter is smart enough to start the system if it's not already going.
|
|---|
| 7 |
|
|---|
| 8 | class Test(Frame):
|
|---|
| 9 | def printit(self):
|
|---|
| 10 | print "hi"
|
|---|
| 11 |
|
|---|
| 12 | def createWidgets(self):
|
|---|
| 13 | self.QUIT = Button(self, text='QUIT',
|
|---|
| 14 | background='red',
|
|---|
| 15 | foreground='white',
|
|---|
| 16 | height=3,
|
|---|
| 17 | command=self.quit)
|
|---|
| 18 | self.QUIT.pack(side=BOTTOM, fill=BOTH)
|
|---|
| 19 |
|
|---|
| 20 | self.canvasObject = Canvas(self, width="5i", height="5i")
|
|---|
| 21 | self.canvasObject.pack(side=LEFT)
|
|---|
| 22 |
|
|---|
| 23 | def mouseDown(self, event):
|
|---|
| 24 | # canvas x and y take the screen coords from the event and translate
|
|---|
|
|---|