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