Mercurial > code > home > repos > light9
annotate light8/stage.py @ 7:1b0266dd233a
picking and dragging works pretty well (no ctrl yet)
author | drewp |
---|---|
date | Sun, 07 Jul 2002 04:52:48 +0000 |
parents | 119369e60da1 |
children | 6faae180d1c5 |
rev | line source |
---|---|
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
1 from Tkinter import * |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
2 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
3 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
4 def printevent(ev): |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
5 for k in dir(ev): |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
6 if not k.startswith('__'): |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
7 print k,getattr(ev,k) |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
8 print "" |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
9 |
0 | 10 |
11 class Stage(Canvas): | |
12 | |
13 """a fancy widget that shows light locations (and optionally their | |
14 aim locations on an image of the stage. you can select or | |
15 multiselect lights and drag them up or down to change their | |
16 brightness. | |
17 | |
18 ctrl-a is select all, | |
19 ctrl-shift-a or clicking on no light deselects all, | |
20 re-clicking a light with shift key down toggles whether it's in the selection. | |
21 ctrl-drag-rectangle deselects the lights in the rectangle, | |
22 shift-drag-rectangle selects the lights in the rectangle, | |
23 drag-rectangle selects only the lights in the rectangle. | |
24 | |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
25 a light can be selected on its location point, its aim point |
0 | 26 (which may or may not be present), or its name. |
27 | |
28 lights should be able to be interactively 'locked', which blocks | |
29 them from being selected. | |
30 | |
31 """ | |
32 def __init__(self,parent,**kw): | |
33 Canvas.__init__(self,parent,**kw) | |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
34 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
35 self.bind("<ButtonPress-1>", self.leftpress) |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
36 self.bind("<B1-Motion>", self.leftmotion) |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
37 self.bind("<ButtonRelease-1>", self.leftrelease) |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
38 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
39 self.halo=11 # search radius for clicked items |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
40 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
41 self.lmbstate=None # as you perform with LMB, this goes from None to 'pressed','rectangle','levelchange' |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
42 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
43 self.alllights=[] |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
44 self.selectedlights=[] |
7 | 45 self.alllighttags={} # tag: name lookup |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
46 |
7 | 47 |
48 def setimage(self,stageimage): | |
49 img = Image('photo',file=stageimage) | |
50 self.img=img # can't lose this! | |
51 print img.width() | |
52 self.create_image(0,0,anchor='nw',image=img) | |
53 self.config(width=img.width(),height=img.height()) | |
54 | |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
55 # |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
56 # selection management |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
57 # |
7 | 58 def updateselectionboxes(self): |
59 "make selection boxes that match self.selectedlights" | |
60 self.delete("selectbox") | |
61 for l in self.selectedlights: | |
62 for c in self.getlightbboxes(l): | |
63 self.create_rectangle(c[0]-2,c[1]-2,c[2]+2,c[3]+2,outline='red',tag="selectbox") | |
64 | |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
65 def clearselection(self,dyn=0): |
7 | 66 self.selectedlights=[] |
67 self.updateselectionboxes() | |
68 | |
69 def markfordynselection(self): | |
70 """call this before calls to replacedynselection""" | |
71 self.origselection = self.selectedlights | |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
72 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
73 def replacedynselection(self,newlightnames): |
7 | 74 """as a dynamic selection changes, keep calling this function with the |
75 names of the lights in the dynamic selection. the original selection (at the time | |
76 of markfordynselection) will be shown along with any new lights""" | |
77 self.selectedlights = self.origselection + [l for l in newlightnames if l not in self.origselection] | |
78 self.updateselectionboxes() | |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
79 |
7 | 80 def select(self,lightname,select=1,dyn=0): # select=0 for deselect |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
81 if select: |
7 | 82 if lightname not in self.selectedlights: |
83 self.selectedlights.append(lightname) | |
84 elif lightname in self.selectedlights: | |
85 self.selectedlights.remove(lightname) | |
86 | |
87 self.updateselectionboxes() | |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
88 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
89 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
90 # |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
91 # LMB click or drag |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
92 # |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
93 def leftpress(self,ev): |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
94 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
95 self.lmbstate='pressed' |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
96 self.lmbstart=(ev.x,ev.y) |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
97 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
98 shifted=ev.state & 1 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
99 control=ev.state & 4 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
100 touching=self.findoverlappinglights((ev.x-self.halo,ev.y-self.halo,ev.x+self.halo,ev.y+self.halo)) |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
101 istouching=len(touching)>0 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
102 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
103 if not istouching: |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
104 # clicked in space |
7 | 105 if not shifted and not control and len(self.selectedlights)>0: |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
106 # either a deselect (if no motion) or a level change (if motion) |
7 | 107 self.lmbstate = 'deselect-or-level' |
108 if shifted or control or len(self.selectedlights)==0: | |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
109 # with shift/control, add/subtract lights to selection |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
110 self.lmbstate='rectangle' |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
111 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
112 else: |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
113 # clicked a selectable object |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
114 # toggle selection |
7 | 115 if touching[0] in self.selectedlights: |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
116 if shifted: |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
117 # deselect |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
118 self.select(touching[0],0) |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
119 # and do nothing else |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
120 self.lmbstate=None |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
121 else: |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
122 # select only this light |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
123 self.clearselection() |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
124 self.select(touching[0]) |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
125 # and adjust its level |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
126 self.lmbstate='levelchange' |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
127 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
128 else: |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
129 if not shifted: |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
130 self.clearselection() |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
131 self.select(touching[0]) |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
132 # and adjust levels now |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
133 self.lmbstate='levelchange' |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
134 |
7 | 135 if self.lmbstate=='rectangle': |
136 self.markfordynselection() | |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
137 def leftmotion(self,ev): |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
138 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
139 coords=(ev.x,ev.y) |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
140 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
141 shifted=ev.state & 1 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
142 control=ev.state & 4 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
143 |
7 | 144 if self.lmbstate=='deselect-or-level': |
145 if (coords[0]-self.lmbstart[0])**2+(coords[1]-self.lmbstart[1])**2>self.halo**2: | |
146 # they moved enough, it's a level change | |
147 self.lmbstate='levelchange' | |
148 | |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
149 if self.lmbstate=='levelchange': |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
150 delta = self.lmbstart[1]-ev.y |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
151 print "change by",delta |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
152 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
153 if self.lmbstate=='rectangle': |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
154 sr = self.find_withtag('selectrect') |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
155 if not sr: |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
156 sr=self.create_rectangle( self.lmbstart[0],self.lmbstart[1],coords[0],coords[1],tag='selectrect') |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
157 # sr=self.create_rectangle( *(self.lmbstart+coords), tag='selectrect' ) |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
158 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
159 self.coords(sr,*(self.lmbstart+coords)) |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
160 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
161 # redo the dynselection with the new rectangle |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
162 self.replacedynselection([o for o in self.findoverlappinglights((self.lmbstart+coords),1)]) |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
163 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
164 # need to handle ctrl |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
165 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
166 def leftrelease(self,ev): |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
167 if self.lmbstate: |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
168 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
169 if self.lmbstate=='rectangle': |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
170 self.delete('selectrect') |
7 | 171 |
172 if self.lmbstate=='deselect-or-level': | |
173 # they didn't move enough to promote the mode to level, so it's a deselect click | |
174 self.clearselection() | |
0 | 175 |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
176 # all items that were in dynselection join the selection |
7 | 177 # self.incorporatedynselection() |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
178 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
179 self.lmbstate=None |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
180 |
7 | 181 # |
182 # light names vs. canvas object tags | |
183 # | |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
184 def nametag(self,name): |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
185 "returns a safe version of the name that won't match other names" |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
186 return name.replace(" ","__") |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
187 |
7 | 188 def tagtoname(self,tag): |
189 "finds the real light name for a tag written by nametag()" | |
190 return self.alllighttags[tag] | |
191 | |
192 # | |
193 # light methods | |
194 # | |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
195 def addlight(self,name,location,aim=None): |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
196 tags='light selectable name_%s' % self.nametag(name) |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
197 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
198 self.create_oval(location[0]-2,location[1]-2, |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
199 location[0]+2,location[1]+2, |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
200 fill='red',tag=tags+" hotspot") |
7 | 201 if aim: |
202 self.create_oval(aim[0]-2,aim[1]-2, | |
203 aim[0]+2,aim[1]+2, | |
204 fill='red',tag=tags+" hotspot") | |
205 self.create_line(location[0],location[1],aim[0],aim[1],stipple='gray50', | |
206 arrow='last',arrowshape="9 15 6",tag='light') | |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
207 self.create_text(location[0],location[1]+5,anchor='n',text=name,tag=tags) |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
208 self.alllights.append(name) |
7 | 209 self.alllighttags[self.nametag(name)]=name |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
210 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
211 def getlightbboxes(self,tag): |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
212 """returns a list of bboxes for a light with a given name_ tag. the selection |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
213 mechanism draws around these bboxes to show that a light is selected""" |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
214 bboxes=[] |
7 | 215 for o in self.find_withtag("name_%s" % self.nametag(tag)): |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
216 if 'hotspot' in self.gettags(o): |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
217 bboxes.append(self.bbox(o)) |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
218 return bboxes |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
219 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
220 def findoverlappinglights(self,box,enclosed=0): |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
221 "returns all the different name_ tags for lights that are within (or enclosed by) the box" |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
222 lights=[] |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
223 if enclosed: |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
224 candidates = self.find_enclosed(*box) |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
225 else: |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
226 candidates = self.find_overlapping(*box) |
7 | 227 |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
228 for o in candidates: |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
229 for t in self.gettags(o): |
7 | 230 if t.startswith("name_"): |
231 n = self.tagtoname(t[5:]) | |
232 if n and (n not in lights): | |
233 lights.append(n) | |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
234 return lights |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
235 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
236 root=Tk() |
7 | 237 root.wm_geometry("+376+330") |
238 s=Stage(root) | |
239 s.setimage('guysanddolls.ppm') | |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
240 s.pack() |
7 | 241 s.addlight('drew',(330,640),(90,20)) |
242 s.addlight('house',(360,640)) | |
243 s.addlight('barn',(390,640)) | |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
244 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
245 root.mainloop() |