Mercurial > code > home > repos > light9
annotate light8/panels.py @ 60:f177a2ff34f5
scrolled sub panels
author | drewp |
---|---|
date | Tue, 09 Jul 2002 07:36:45 +0000 |
parents | 032b2b67bc10 |
children | 2508c6b7a4e0 |
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) | |
90 sw.window.bind("<ButtonPress-4>",lambda s=sw.vsb: scrollscrolledwindow(s,-1)) | |
91 sw.window.bind("<ButtonPress-5>",lambda s=sw.vsb: scrollscrolledwindow(s,1)) | |
92 sw.pack(expand=1,fill=BOTH) | |
93 if p==scenesparent: | |
94 scenesparent = sw.window | |
95 else: | |
96 effectsparent = sw.window | |
97 | |
0 | 98 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
|
99 # choose one of the sub panels to add to |
0 | 100 if sub.is_effect: |
101 parent=effectsparent | |
30
e9d2e7754fd9
sideways subs, new x/y buttons (which don't draw right, but they work)
drewp
parents:
26
diff
changeset
|
102 side1='bottom' |
48
2ef72bb3a707
finished the re-class of Console so it can make new subs again
drewp
parents:
43
diff
changeset
|
103 side2='left' |
38 | 104 orient1='vert' |
32 | 105 end1=0 |
106 end2=1 | |
38 | 107 width1=len(name) |
0 | 108 else: |
109 parent=scenesparent | |
30
e9d2e7754fd9
sideways subs, new x/y buttons (which don't draw right, but they work)
drewp
parents:
26
diff
changeset
|
110 side1='right' |
48
2ef72bb3a707
finished the re-class of Console so it can make new subs again
drewp
parents:
43
diff
changeset
|
111 side2='top' |
38 | 112 orient1='horiz' |
32 | 113 end1=1 |
114 end2=0 | |
38 | 115 width1=longestname |
0 | 116 |
30
e9d2e7754fd9
sideways subs, new x/y buttons (which don't draw right, but they work)
drewp
parents:
26
diff
changeset
|
117 # 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
|
118 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
|
119 f.pack(fill='both',exp=1,side=side2) |
60 | 120 |
0 | 121 |
53 | 122 # make DoubleVar (there might be one left around from |
123 # before a refresh) | |
0 | 124 if name not in scalelevels: |
125 scalelevels[name]=DoubleVar() | |
126 | |
127 sub.set_slider_var(scalelevels[name]) | |
128 | |
53 | 129 scaleopts = {'troughcolor' : 'grey70'} |
0 | 130 if sub.color: |
131 scaleopts['troughcolor'] = sub.color | |
19 | 132 |
133 s = FlyingFader(f, label=str(name), variable=scalelevels[name], | |
60 | 134 showvalue=0, length=100, |
53 | 135 width=14, sliderlength=14, |
136 to=end1,res=.001,from_=end2,bd=1, font=stdfont, | |
38 | 137 orient=orient1, |
138 labelwidth=width1, | |
30
e9d2e7754fd9
sideways subs, new x/y buttons (which don't draw right, but they work)
drewp
parents:
26
diff
changeset
|
139 **scaleopts) |
0 | 140 |
60 | 141 # tell subediting what widgets to highlight when it's |
53 | 142 # editing a sub |
143 for w in (s,s.label,s.vlabel, s.scale): | |
144 subediting.register(subname=name,widget=w) | |
38 | 145 |
53 | 146 if not sub.is_effect: |
147 self.subeditingbuttons(f,side1,sub,name,lightboard,subediting) | |
148 | |
149 self.axisbuttons(f,s,xfader,stdfont,side1,name) | |
0 | 150 |
60 | 151 s.pack(side='left', fill=BOTH, expand=1) |
0 | 152 |
153 # effects frame? | |
154 sframe = Frame(f,bd=2,relief='groove') | |
155 sub.draw_tk(sframe) | |
156 sframe.pack(side='left',fill='y') | |
53 | 157 |
158 def subediting_edit(self,subediting,sub): | |
159 subediting.setsub(sub) | |
160 | |
161 def subediting_save(self,name,sub,lightboard): | |
162 lightboard.save_sub(name,sub.getlevels()) | |
163 | |
164 def subeditingbuttons(self,f,side1,sub,name,lightboard,subediting): | |
165 for txt,cmd in (("Edit",lambda subediting=subediting,sub=sub: self.subediting_edit(subediting,sub)), | |
166 ("Save",lambda sub=sub,name=name,lightboard=lightboard: self.subediting_save(name,sub,lightboard))): | |
167 eb = Button(f,text=txt,font=stdfont,padx=0,pady=0, | |
168 bd=1,command=cmd) | |
169 eb.pack(side=side1,fill='both',padx=0,pady=0) | |
170 | |
171 def axisbuttons(self,f,s,xfader,stdfont,side1,name): | |
172 for axis in ('y','x'): | |
173 cvar=IntVar() | |
174 eb_color = ('red', 'green')[axis == 'y'] | |
175 cb=Togglebutton(f,text=axis.upper(),variable=cvar,font=stdfont, | |
176 padx=3, pady=0, bd=1, downcolor=eb_color) | |
177 cb.pack(side=side1,fill='both', padx=0, pady=0) | |
178 s.bind('<Key-%s>'%axis, lambda ev,cb=cb: cb.invoke) | |
179 xfader.registerbutton(name,axis,cvar) | |
180 | |
181 |