Ditched '_find_SET()', since it was a no-value-added wrapper around
[python/dscho.git] / Demo / tkinter / matt / canvas-reading-tag-info.py
blob704469177e5f7bca896b43b876228780a74f1fa0
1 from Tkinter import *
4 class Test(Frame):
5 def printit(self):
6 print "hi"
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)
13 self.drawing = Canvas(self, width="5i", height="5i")
15 # make a shape
16 pgon = self.drawing.create_polygon(
17 10, 10, 110, 10, 110, 110, 10 , 110,
18 fill="red", tags=("weee", "foo", "groo"))
20 # this is how you query an object for its attributes
21 # config options FOR CANVAS ITEMS always come back in tuples of length 5.
22 # 0 attribute name
23 # 1 BLANK
24 # 2 BLANK
25 # 3 default value
26 # 4 current value
27 # the blank spots are for consistency with the config command that
28 # is used for widgets. (remember, this is for ITEMS drawn
29 # on a canvas widget, not widgets)
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], "<--"
36 ## here we print out all the tags associated with this object
37 option_value = self.drawing.itemconfig(pgon, "tags")
38 print "pgon's tags are", option_value[4]
40 self.drawing.pack(side=LEFT)
42 def __init__(self, master=None):
43 Frame.__init__(self, master)
44 Pack.config(self)
45 self.createWidgets()
47 test = Test()
49 test.mainloop()