Mercurial > code > home > repos > light9
annotate light8/panels.py @ 61:2508c6b7a4e0
scrolled sub panels which work
author | drewp |
---|---|
date | Tue, 09 Jul 2002 07:52:48 +0000 |
parents | f177a2ff34f5 |
children | 8b6befd8b97e |
rev | line source |
---|---|
0 | 1 """some of the panels""" |
48
2ef72bb3a707
finished the re-class of Console so it can make new subs again
drewp
parents:
43
diff
changeset
|
2 from __future__ import nested_scopes |
0 | 3 |
51
71489bb71528
- Meet Fader. He is going to grow up and be a crossfader some day
dmcc
parents:
48
diff
changeset
|
4 from Tix import * |
0 | 5 from uihelpers import * |
6 import Patch | |
19 | 7 from FlyingFader import FlyingFader |
30
e9d2e7754fd9
sideways subs, new x/y buttons (which don't draw right, but they work)
drewp
parents:
26
diff
changeset
|
8 import Pmw |
0 | 9 |
10 stdfont = ('Arial', 8) | |
11 monofont = ('Courier', 8) | |
12 | |
13 class Controlpanel(Frame): | |
26 | 14 def __init__(self, parent, xfader, refresh_cb, quit_cb): |
12
7adc65771676
big restructuring - moved lots of things (including most panels) to other files
drewp
parents:
0
diff
changeset
|
15 Frame.__init__(self,parent) |
26 | 16 controlpanel = self |
0 | 17 for txt,cmd in ( |
18 ('Quit', quit_cb), | |
19 ('Refresh', refresh_cb), | |
20 ('Clear all', xfader.clearallbuttons), | |
21 ('On -> X', lambda: xfader.grab('x')), | |
22 ('Clear X', lambda: xfader.clearallbuttons('x')), | |
23 ('On -> Y', lambda: xfader.grab('y')), | |
12
7adc65771676
big restructuring - moved lots of things (including most panels) to other files
drewp
parents:
0
diff
changeset
|
24 ('Clear Y', lambda: xfader.clearallbuttons('y'))): |
26 | 25 Button(controlpanel, text=txt, command=cmd).pack(side='top', |
26 fill='x') | |
0 | 27 |
28 class Console: | |
53 | 29 def __init__(self,lightboard): |
12
7adc65771676
big restructuring - moved lots of things (including most panels) to other files
drewp
parents:
0
diff
changeset
|
30 print "Light 8: Everything's under control" |
7adc65771676
big restructuring - moved lots of things (including most panels) to other files
drewp
parents:
0
diff
changeset
|
31 t=toplevelat(267,717,w=599,h=19) |
7adc65771676
big restructuring - moved lots of things (including most panels) to other files
drewp
parents:
0
diff
changeset
|
32 self.frame = Frame(t) |
7adc65771676
big restructuring - moved lots of things (including most panels) to other files
drewp
parents:
0
diff
changeset
|
33 self.entry=Entry(self.frame) |
0 | 34 self.entry.pack(expand=1, fill='x') |
48
2ef72bb3a707
finished the re-class of Console so it can make new subs again
drewp
parents:
43
diff
changeset
|
35 self.entry.bind('<Return>', |
2ef72bb3a707
finished the re-class of Console so it can make new subs again
drewp
parents:
43
diff
changeset
|
36 lambda evt: self.execute(evt, self.entry.get())) |
0 | 37 self.frame.pack(fill=BOTH, expand=1) |
53 | 38 self.lightboard=lightboard |
0 | 39 |
48
2ef72bb3a707
finished the re-class of Console so it can make new subs again
drewp
parents:
43
diff
changeset
|
40 def execute(self, evt, str): |
53 | 41 if str[0] == '*': # make a new sub from the current levels |
42 self.lightboard.save_sub(str,self.lightboard.stageassub()) | |
0 | 43 else: |
44 print '>>>', str | |
45 print eval(str) | |
53 | 46 self.frame.focus() |
48
2ef72bb3a707
finished the re-class of Console so it can make new subs again
drewp
parents:
43
diff
changeset
|
47 |
0 | 48 class Leveldisplay: |
26 | 49 def __init__(self, parent, channel_levels, num_channels=68): |
0 | 50 frames = (make_frame(parent), make_frame(parent)) |
16 | 51 channel_levels[:]=[] |
34
411de8b46aef
the famous you-are-in-the-process-of-changing-this-light indicator.
dmcc
parents:
32
diff
changeset
|
52 self.number_labels = [] |
26 | 53 for channel in range(1, num_channels+1): |
54 | |
55 # frame for this channel | |
56 f = Frame(frames[channel > (num_channels/2)]) | |
57 # channel number -- will turn yellow when being altered | |
58 num_lab = Label(f, text=str(channel), width=3, bg='lightPink', | |
59 font=stdfont, padx=0, pady=0, bd=0, height=1) | |
60 num_lab.pack(side='left') | |
34
411de8b46aef
the famous you-are-in-the-process-of-changing-this-light indicator.
dmcc
parents:
32
diff
changeset
|
61 self.number_labels.append(num_lab) |
26 | 62 |
63 # text description of channel | |
64 Label(f, text=Patch.get_channel_name(channel), width=8, | |
65 font=stdfont, anchor='w', padx=0, pady=0, bd=0, | |
66 height=1).pack(side='left') | |
67 | |
68 # current level of channel, shows intensity with color | |
69 l = Label(f, width=3, bg='lightBlue', font=stdfont, anchor='e', | |
70 padx=1, pady=0, bd=0, height=1) | |
0 | 71 l.pack(side='left') |
72 colorlabel(l) | |
73 channel_levels.append(l) | |
74 f.pack(side='top') | |
26 | 75 |
76 self.channel_levels = channel_levels | |
77 # channel_levels is an output - changelevel will use it to access | |
78 # these labels | |
0 | 79 |
80 class Subpanels: | |
53 | 81 def __init__(self, scenesparent, effectsparent, lightboard, |
82 scalelevels, Subs, xfader, | |
83 changelevel, subediting, longestname): | |
0 | 84 |
85 sublist = Subs.subs.items() | |
86 sublist.sort() | |
87 | |
60 | 88 for p in scenesparent,effectsparent: |
89 sw = ScrolledWindow(p) | |
61 | 90 for but,units in ( (4,-4),(5,4) ): |
91 sw.window.bind("<ButtonPress-%s>"%but,lambda ev,s=sw.vsb,u=units: s.tk.call('tkScrollByUnits',s,'hv',u)) | |
92 | |
60 | 93 sw.pack(expand=1,fill=BOTH) |
94 if p==scenesparent: | |
95 scenesparent = sw.window | |
96 else: | |
97 effectsparent = sw.window | |
98 | |
0 | 99 for name, sub in sublist: |
30
e9d2e7754fd9
sideways subs, new x/y buttons (which don't draw right, but they work)
drewp
parents:
26
diff
changeset
|
100 # choose one of the sub panels to add to |
0 | 101 if sub.is_effect: |
102 parent=effectsparent | |
30
e9d2e7754fd9
sideways subs, new x/y buttons (which don't draw right, but they work)
drewp
parents:
26
diff
changeset
|
103 side1='bottom' |
48
2ef72bb3a707
finished the re-class of Console so it can make new subs again
drewp
parents:
43
diff
changeset
|
104 side2='left' |
38 | 105 orient1='vert' |
32 | 106 end1=0 |
107 end2=1 | |
38 | 108 width1=len(name) |
0 | 109 else: |
110 parent=scenesparent | |
30
e9d2e7754fd9
sideways subs, new x/y buttons (which don't draw right, but they work)
drewp
parents:
26
diff
changeset
|
111 side1='right' |
48
2ef72bb3a707
finished the re-class of Console so it can make new subs again
drewp
parents:
43
diff
changeset
|
112 side2='top' |
38 | 113 orient1='horiz' |
32 | 114 end1=1 |
115 end2=0 | |
38 | 116 width1=longestname |
0 | 117 |
30
e9d2e7754fd9
sideways subs, new x/y buttons (which don't draw right, but they work)
drewp
parents:
26
diff
changeset
|
118 # make frame that surrounds the whole submaster |
12
7adc65771676
big restructuring - moved lots of things (including most panels) to other files
drewp
parents:
0
diff
changeset
|
119 f=Frame(parent, bd=1, relief='raised') |
48
2ef72bb3a707
finished the re-class of Console so it can make new subs again
drewp
parents:
43
diff
changeset
|
120 f.pack(fill='both',exp=1,side=side2) |
60 | 121 |
0 | 122 |
53 | 123 # make DoubleVar (there might be one left around from |
124 # before a refresh) | |
0 | 125 if name not in scalelevels: |
126 scalelevels[name]=DoubleVar() | |
127 | |
128 sub.set_slider_var(scalelevels[name]) | |
129 | |
53 | 130 scaleopts = {'troughcolor' : 'grey70'} |
0 | 131 if sub.color: |
132 scaleopts['troughcolor'] = sub.color | |
19 | 133 |
134 s = FlyingFader(f, label=str(name), variable=scalelevels[name], | |
60 | 135 showvalue=0, length=100, |
53 | 136 width=14, sliderlength=14, |
137 to=end1,res=.001,from_=end2,bd=1, font=stdfont, | |
38 | 138 orient=orient1, |
139 labelwidth=width1, | |
30
e9d2e7754fd9
sideways subs, new x/y buttons (which don't draw right, but they work)
drewp
parents:
26
diff
changeset
|
140 **scaleopts) |
0 | 141 |
60 | 142 # tell subediting what widgets to highlight when it's |
53 | 143 # editing a sub |
144 for w in (s,s.label,s.vlabel, s.scale): | |
145 subediting.register(subname=name,widget=w) | |
38 | 146 |
53 | 147 if not sub.is_effect: |
148 self.subeditingbuttons(f,side1,sub,name,lightboard,subediting) | |
149 | |
150 self.axisbuttons(f,s,xfader,stdfont,side1,name) | |
0 | 151 |
60 | 152 s.pack(side='left', fill=BOTH, expand=1) |
0 | 153 |
154 # effects frame? | |
155 sframe = Frame(f,bd=2,relief='groove') | |
156 sub.draw_tk(sframe) | |
157 sframe.pack(side='left',fill='y') | |
53 | 158 |
159 def subediting_edit(self,subediting,sub): | |
160 subediting.setsub(sub) | |
161 | |
162 def subediting_save(self,name,sub,lightboard): | |
163 lightboard.save_sub(name,sub.getlevels()) | |
164 | |
165 def subeditingbuttons(self,f,side1,sub,name,lightboard,subediting): | |
166 for txt,cmd in (("Edit",lambda subediting=subediting,sub=sub: self.subediting_edit(subediting,sub)), | |
167 ("Save",lambda sub=sub,name=name,lightboard=lightboard: self.subediting_save(name,sub,lightboard))): | |
168 eb = Button(f,text=txt,font=stdfont,padx=0,pady=0, | |
169 bd=1,command=cmd) | |
170 eb.pack(side=side1,fill='both',padx=0,pady=0) | |
171 | |
172 def axisbuttons(self,f,s,xfader,stdfont,side1,name): | |
173 for axis in ('y','x'): | |
174 cvar=IntVar() | |
175 eb_color = ('red', 'green')[axis == 'y'] | |
176 cb=Togglebutton(f,text=axis.upper(),variable=cvar,font=stdfont, | |
177 padx=3, pady=0, bd=1, downcolor=eb_color) | |
178 cb.pack(side=side1,fill='both', padx=0, pady=0) | |
179 s.bind('<Key-%s>'%axis, lambda ev,cb=cb: cb.invoke) | |
180 xfader.registerbutton(name,axis,cvar) | |
181 | |
182 |