| 1 |
from Tkinter import * |
| 2 |
|
| 3 |
|
| 4 |
class Test(Frame): |
| 5 |
def printit(self): |
| 6 |
print "hi" |
| 7 |
|
| 8 |
def createWidgets(self): |
| 9 |
self.QUIT = Button(self, text='QUIT', foreground='red', |
| 10 |
command=self.quit) |
| 11 |
self.QUIT.pack(side=BOTTOM, fill=BOTH) |
| 12 |
|
| 13 |
self.drawing = Canvas(self, width="5i", height="5i") |
| 14 |
|
| 15 |
|
| 16 |
pgon = self.drawing.create_polygon( |
| 17 |
10, 10, 110, 10, 110, 110, 10 , 110, |
| 18 |
fill="red", tags=("weee", "foo", "groo")) |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
option_value = self.drawing.itemconfig(pgon, "stipple") |
| 31 |
print "pgon's current stipple value is -->", option_value[4], "<--" |
| 32 |
option_value = self.drawing.itemconfig(pgon, "fill") |
| 33 |
print "pgon's current fill value is -->", option_value[4], "<--" |
| 34 |
print " when he is usually colored -->", option_value[3], "<--" |
| 35 |
|
| 36 |
|
| 37 |
option_value = self.drawing.itemconfig(pgon, "tags") |
| 38 |
print "pgon's tags are", option_value[4] |
| 39 |
|
| 40 |
self.drawing.pack(side=LEFT) |
| 41 |
|
| 42 |
def __init__(self, master=None): |
| 43 |
Frame.__init__(self, master) |
| 44 |
Pack.config(self) |
| 45 |
self.createWidgets() |
| 46 |
|
| 47 |
test = Test() |
| 48 |
|
| 49 |
test.mainloop() |