Mercurial > code > home > repos > light9
annotate light8/stage.py @ 2405:69ca2b2fc133
overcomplicated attempt at persisting the pane layout in the rdf graph
this was hard because we have to somehow wait for the graph to load before config'ing the panes
author | drewp@bigasterisk.com |
---|---|
date | Fri, 17 May 2024 16:58:26 -0700 |
parents | fca9832d207f |
children |
rev | line source |
---|---|
51
71489bb71528
- Meet Fader. He is going to grow up and be a crossfader some day
dmcc
parents:
44
diff
changeset
|
1 from Tix import * |
6
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 def printevent(ev): |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
4 for k in dir(ev): |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
5 if not k.startswith('__'): |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
6 print k,getattr(ev,k) |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
7 print "" |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
8 |
53 | 9 textstyle={'font':'arial 9','fill':'white'} |
14 | 10 |
0 | 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 | |
17 | 31 API: |
32 __init__(parent,**kw) | |
33 put pass any canvas options you want | |
34 | |
35 setimage(stageimage) | |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
36 sets image to given filename (ppm, gif, etc) and resizes the |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
37 canvas to the image size |
17 | 38 |
39 addlight(name, location, aim=None) | |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
40 location and aim are pixel coord tuples. name will be passed |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
41 back to you in the callback (see below) |
17 | 42 |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
43 setsubediting(se) |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
44 give a subediting object to receive the 'startlevelchange' and |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
45 'levelchange' messages |
17 | 46 |
47 | |
0 | 48 """ |
49 def __init__(self,parent,**kw): | |
50 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
|
51 |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
52 self.bind("<ButtonPress>", self.press) |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
53 self.bind("<Motion>", self.motion) |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
54 self.bind("<ButtonRelease>", self.release) |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
55 self.bind("<Control-Key-a>", lambda ev: self.selectall()) |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
56 self.bind("<Control-Key-A>", lambda ev: self.clearselection()) |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
57 # self.bind("<Control-Shift-Key-a>",self.handlecontrol_a) |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
58 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
59 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
|
60 |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
61 self.mode=None # as you perform with the mouse, this goes |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
62 # from None to 'pressed','rectangle','levelchange', etc |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
63 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
64 self.alllights=[] |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
65 self.selectedlights=[] |
7 | 66 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
|
67 |
62
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
68 self.subeditor = None |
7 | 69 |
77 | 70 |
7 | 71 def setimage(self,stageimage): |
72 img = Image('photo',file=stageimage) | |
73 self.img=img # can't lose this! | |
102 | 74 # print img.width() |
238 | 75 self.create_image(0,0,anchor='nw',image=img) |
76 self.config(width=img.width(),height=img.height()) | |
77 | 77 |
78 # we had the picture removed for good luck, but we remember | |
79 # what the dimensions formerly was | |
101 | 80 self.config(width=821,height=681, bg="grey40") |
77 | 81 |
37
115636cca107
subeditor begins to work - stage makes the right calls to subeditor now
drewp
parents:
17
diff
changeset
|
82 |
115636cca107
subeditor begins to work - stage makes the right calls to subeditor now
drewp
parents:
17
diff
changeset
|
83 def setsubediting(self,subeditor): |
115636cca107
subeditor begins to work - stage makes the right calls to subeditor now
drewp
parents:
17
diff
changeset
|
84 self.subeditor = subeditor |
62
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
85 |
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
86 # (17:00:06) drewp: if yes, then self.itemconfigure(tagOrId, text=...) |
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
87 def updatelightlevel(self, name, level): |
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
88 tag = self.nametag(name) |
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
89 self.itemconfigure("level_%s" % tag, text=level) |
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
90 |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
91 # |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
92 # selection management |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
93 # |
7 | 94 def updateselectionboxes(self): |
95 "make selection boxes that match self.selectedlights" | |
96 self.delete("selectbox") | |
97 for l in self.selectedlights: | |
98 for c in self.getlightbboxes(l): | |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
99 self.create_rectangle(c[0]-2,c[1]-2,c[2]+2,c[3]+2, |
62
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
100 outline='red',tag="selectbox") |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
101 |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
102 def selectall(self): |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
103 self.selectedlights= self.alllights[:] |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
104 self.updateselectionboxes() |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
105 def clearselection(self): |
7 | 106 self.selectedlights=[] |
107 self.updateselectionboxes() | |
108 | |
109 def markfordynselection(self): | |
110 """call this before calls to replacedynselection""" | |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
111 self.origselection = self.selectedlights[:] |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
112 |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
113 def replacedynselection(self,newlightnames,subtract=0): |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
114 """as a dynamic selection changes, keep calling this function |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
115 with the names of the lights in the dynamic selection. the |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
116 original selection (at the time of markfordynselection) will |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
117 be shown along with any new lights. if subtract=1, the selection will |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
118 be shown MINUS the newlights.""" |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
119 if subtract==0: |
62
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
120 # orig selection plus any newlights that weren't in the orig |
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
121 # selection |
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
122 self.selectedlights = self.origselection[:] + \ |
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
123 [l for l in newlightnames if l not in self.origselection] |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
124 else: |
62
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
125 # orig selection lights except those that are in the newlightnames |
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
126 # list |
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
127 self.selectedlights = [l for l in self.origselection |
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
128 if l not in newlightnames] |
7 | 129 self.updateselectionboxes() |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
130 |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
131 def select(self,lightname,select=1): # select=0 for deselect |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
132 """select or deselect (select=0) a light by name""" |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
133 if select: |
7 | 134 if lightname not in self.selectedlights: |
135 self.selectedlights.append(lightname) | |
136 elif lightname in self.selectedlights: | |
137 self.selectedlights.remove(lightname) | |
138 | |
139 self.updateselectionboxes() | |
6
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 # |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
142 # mouse handling |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
143 # |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
144 def press(self,ev): |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
145 |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
146 self.mode='pressed' |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
147 self.mousedownpos=(ev.x,ev.y) |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
148 print "click at",self.mousedownpos |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
149 |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
150 button=ev.num |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
151 shifted=ev.state & 1 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
152 control=ev.state & 4 |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
153 touching=self.findoverlappinglights((ev.x-self.halo,ev.y-self.halo, |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
154 ev.x+self.halo,ev.y+self.halo)) |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
155 istouching=len(touching)>0 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
156 |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
157 if button==1: |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
158 if not istouching: |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
159 # clicked in space |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
160 if not shifted and not control and len(self.selectedlights)>0: |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
161 # either a deselect (if no motion) or a level change (if motion) |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
162 self.mode = 'deselect-or-rectangle' |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
163 if shifted or control or len(self.selectedlights)==0: |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
164 # with shift/control, add/subtract lights to selection |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
165 self.startrectangleselect() |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
166 |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
167 else: |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
168 # clicked a selectable object |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
169 # toggle selection |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
170 if touching[0] in self.selectedlights: |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
171 if shifted or control: |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
172 # deselect |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
173 self.select(touching[0],0) |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
174 # and do nothing else |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
175 self.mode=None |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
176 if not shifted: |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
177 # select only this light |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
178 self.clearselection() |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
179 self.select(touching[0]) |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
180 # and adjust its level |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
181 self.startlevelchange() |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
182 |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
183 else: |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
184 # clicked a light that wasn't selected |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
185 if not shifted: |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
186 self.clearselection() |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
187 self.select(touching[0]) |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
188 # and adjust levels now |
37
115636cca107
subeditor begins to work - stage makes the right calls to subeditor now
drewp
parents:
17
diff
changeset
|
189 self.startlevelchange() |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
190 |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
191 if button==3: |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
192 self.startlevelchange() |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
193 |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
194 def motion(self,ev): |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
195 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
196 coords=(ev.x,ev.y) |
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 shifted=ev.state & 1 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
199 control=ev.state & 4 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
200 |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
201 if self.mode=='deselect-or-rectangle': |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
202 if (coords[0]-self.mousedownpos[0])**2+(coords[1]-self.mousedownpos[1])**2>self.halo**2: |
53 | 203 if not shifted and not control: |
204 self.clearselection() | |
7 | 205 # they moved enough, it's a level change |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
206 self.startrectangleselect() |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
207 |
7 | 208 |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
209 if self.mode=='levelchange': |
53 | 210 delta = 1.5 * (self.mousedownpos[1]-ev.y) |
37
115636cca107
subeditor begins to work - stage makes the right calls to subeditor now
drewp
parents:
17
diff
changeset
|
211 if self.subeditor: |
115636cca107
subeditor begins to work - stage makes the right calls to subeditor now
drewp
parents:
17
diff
changeset
|
212 self.subeditor.levelchange(self.selectedlights,delta) |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
213 |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
214 if self.mode=='rectangle': |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
215 sr = self.find_withtag('selectrect') |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
216 if not sr: |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
217 # make the selection rectangle |
62
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
218 sr=self.create_rectangle( self.mousedownpos[0], |
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
219 self.mousedownpos[1],coords[0],coords[1], |
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
220 outlinestipple='gray50',outline='yellow',tag='selectrect') |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
221 |
8 | 222 # move rectangle with mouse |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
223 self.coords(sr,*(self.mousedownpos+coords)) |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
224 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
225 # redo the dynselection with the new rectangle |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
226 self.replacedynselection(self.findoverlappinglights((self.mousedownpos+coords),1), |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
227 subtract=control) |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
228 |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
229 def release(self,ev): |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
230 if self.mode: |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
231 if self.mode=='rectangle': |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
232 self.delete('selectrect') |
7 | 233 |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
234 if self.mode=='deselect-or-rectangle': |
62
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
235 # they didn't move enough to promote the mode to level, so |
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
236 # it's a deselect click |
7 | 237 self.clearselection() |
0 | 238 |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
239 self.mode=None |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
240 |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
241 # |
62
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
242 # subedit type things (correct me if i'm wrong) |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
243 # |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
244 |
37
115636cca107
subeditor begins to work - stage makes the right calls to subeditor now
drewp
parents:
17
diff
changeset
|
245 def startlevelchange(self): |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
246 """sets mode to levelchange AND notifies subeditor. this |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
247 should be done exactly once (per mouse drag), when you first |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
248 decide the mode is levelchange""" |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
249 self.mode='levelchange' |
37
115636cca107
subeditor begins to work - stage makes the right calls to subeditor now
drewp
parents:
17
diff
changeset
|
250 if self.subeditor: |
115636cca107
subeditor begins to work - stage makes the right calls to subeditor now
drewp
parents:
17
diff
changeset
|
251 self.subeditor.startlevelchange() |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
252 def startrectangleselect(self): |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
253 """sets mode to rectangle AND checkpoints the current selection""" |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
254 self.mode='rectangle' |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
255 self.markfordynselection() |
7 | 256 # |
257 # light names vs. canvas object tags | |
258 # | |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
259 def nametag(self,name): |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
260 "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
|
261 return name.replace(" ","__") |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
262 |
7 | 263 def tagtoname(self,tag): |
264 "finds the real light name for a tag written by nametag()" | |
265 return self.alllighttags[tag] | |
266 | |
267 # | |
268 # light methods | |
269 # | |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
270 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
|
271 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
|
272 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
273 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
|
274 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
|
275 fill='red',tag=tags+" hotspot") |
7 | 276 if aim: |
277 self.create_oval(aim[0]-2,aim[1]-2, | |
278 aim[0]+2,aim[1]+2, | |
62
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
279 fill='blue',tag=tags+" hotspot") |
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
280 self.create_line(location[0],location[1],aim[0],aim[1], |
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
281 fill='lightblue', arrow='last',arrowshape="9 15 6",tag='light') |
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
282 |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
283 # shadow |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
284 self.create_text(location[0]-1,location[1]+6, |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
285 anchor='n',text=name,fill='black', |
62
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
286 tag=tags,**dict([(k,v) |
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
287 for k,v in textstyle.items() if k!='fill'])) |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
288 # text |
62
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
289 self.create_text(location[0],location[1]+5,anchor='n',text=name, |
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
290 tag=tags,**textstyle) |
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
291 |
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
292 # level |
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
293 self.create_text(location[0]-2,location[1]+13,anchor='n', |
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
294 text='0', # will be changed later |
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
295 tag='level_%s' % self.nametag(name),**textstyle) |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
296 |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
297 self.alllights.append(name) |
7 | 298 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
|
299 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
300 def getlightbboxes(self,tag): |
62
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
301 """returns a list of bboxes for a light with a given name_ tag. the |
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
302 selection mechanism draws around these bboxes to show that a light is |
2f2eb802e93d
stage shows levels now. aims have blue halo for easy recognition.
dmcc
parents:
53
diff
changeset
|
303 selected""" |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
304 bboxes=[] |
7 | 305 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
|
306 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
|
307 bboxes.append(self.bbox(o)) |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
308 return bboxes |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
309 |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
310 def findoverlappinglights(self,box,enclosed=0): |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
311 "returns all the different names for lights that are within (or enclosed by) the box" |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
312 lights=[] |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
313 if enclosed: |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
314 candidates = self.find_enclosed(*box) |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
315 else: |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
316 candidates = self.find_overlapping(*box) |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
317 |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
318 for o in candidates: |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
319 for t in self.gettags(o): |
7 | 320 if t.startswith("name_"): |
321 n = self.tagtoname(t[5:]) | |
322 if n and (n not in lights): | |
323 lights.append(n) | |
6
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
324 return lights |
119369e60da1
tag-heavy selection management is getting hard - about to switch to python lists
drewp
parents:
5
diff
changeset
|
325 |
10 | 326 |
14 | 327 def createlights(s): |
328 s.setimage('guysanddolls.gif') | |
329 s.addlight('desk1',(46, 659), aim=(210, 381)) | |
330 s.addlight('marry1',(78, 661), aim=(398, 428)) | |
331 s.addlight('b13',(110, 661)) | |
332 s.addlight('hotbox1',(147, 657), aim=(402, 327)) | |
333 s.addlight('edge',(179, 651), aim=(116, 441)) | |
334 s.addlight('phone',(214, 652), aim=(651, 417)) | |
335 s.addlight('cuba1',(315, 656), aim=(559, 407)) | |
336 s.addlight('b22',(347, 661), aim=(247, 458)) | |
337 s.addlight('b23',(379, 661)) | |
338 s.addlight('b24',(417, 661)) | |
339 s.addlight('b25',(455, 658), aim=(520, 466)) | |
340 s.addlight('desk2',(490, 655), aim=(237, 375)) | |
341 s.addlight('rock',(571, 655), aim=(286, 304)) | |
342 s.addlight('b32',(606, 650)) | |
343 s.addlight('hotbox2',(637, 650), aim=(433, 337)) | |
344 s.addlight('b34',(671, 651)) | |
345 s.addlight('marry2',(703, 651), aim=(429, 426)) | |
346 s.addlight('cuba2',(733, 652), aim=(602, 408)) | |
347 | |
348 s.addlight('sidefill1',(115, 473),aim=(228, 423)) | |
349 s.addlight('sidefill2',(617, 475),aim=(526, 425)) | |
350 | |
351 s.addlight('cycright',(485, 164),(483, 109)) | |
352 s.addlight('cycleft',(330, 154),(333, 108)) | |
353 | |
354 s.addlight('upfill1',(275, 325),(262, 237)) | |
355 s.addlight('upfill2',(333, 326),(330, 229)) | |
356 s.addlight('upfill3',(473, 325),(454, 226)) | |
357 s.addlight('upfill4',(541, 325),(528, 223)) | |
358 | |
359 s.addlight('god',(369,549)) | |
360 | |
361 s.addlight('patio1',(42, 560),(12, 512)) | |
362 s.addlight('patio2',(675, 553),(793, 514)) | |
363 | |
364 s.addlight('hotback',(413, 476),(414, 396)) | |
10 | 365 |
53 | 366 s.addlight('main 2',(120, 563) ,aim=(241, 472)) |
367 s.addlight('main 3',(162, 562) ,aim=(140, 425)) | |
368 s.addlight('main 4',(208, 560) ,aim=(342, 423)) | |
369 s.addlight('main 5',(259, 558) ,aim=(433, 450)) | |
370 s.addlight('main 7',(494, 551) ,aim=(420, 458)) | |
371 s.addlight('main 8',(528, 554) ,aim=(503, 477)) | |
372 s.addlight('main 9',(559, 554) ,aim=(544, 479)) | |
373 s.addlight('main 10',(597, 556),aim=(339, 444)) | |
374 s.addlight('main 11',(636, 556),aim=(449, 409)) | |
375 | |
65 | 376 s.addlight('side r', (785, 609)) |
377 s.addlight('side l', (8, 613)) | |
53 | 378 |
69 | 379 s.addlight('cafe1',(174, 476)) |
380 s.addlight('cafe2',(584, 475)) | |
381 s.addlight('dream',(329, 477),aim=(267, 309)) | |
382 s.addlight('xmas',(555, 56),aim=(438, 284)) | |
383 | |
384 for y,col in ((300,'red'),(333,'blue'),(364,'gree'),(407,'oran')): | |
385 for i in range(1,5): | |
386 s.addlight('%s%s' % (col,i),(726+10*i,y)) | |
387 | |
14 | 388 if __name__=='__main__': |
389 root=Tk() | |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
390 root.tk_focusFollowsMouse() |
14 | 391 root.wm_geometry("+376+330") |
392 s=Stage(root) | |
393 s.setimage('guysanddolls.gif') | |
394 s.pack() | |
395 | |
396 createlights(s) | |
44
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
397 |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
398 class subediting_standin: |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
399 def startlevelchange(self): |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
400 print "start lev change" |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
401 def levelchange(self,lights,delta): |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
402 print "change",lights,delta |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
403 s.setsubediting(subediting_standin()) |
6540879e336e
fixed Stage a lot: ctrl-drag subtracts from selection; ctrl-a/ctrl-A select all/none;
drewp
parents:
37
diff
changeset
|
404 |
14 | 405 root.mainloop() |