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