annotate light8/panels.py @ 48:2ef72bb3a707

finished the re-class of Console so it can make new subs again
author drewp
date Sun, 07 Jul 2002 15:12:38 +0000
parents 2cd759c2b3c7
children 71489bb71528
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
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
45b12307c695 Initial revision
drewp
parents:
diff changeset
3
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 0
diff changeset
4 from Tkinter import *
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
5 from uihelpers import *
45b12307c695 Initial revision
drewp
parents:
diff changeset
6 import Patch
19
6284a812da50 makefile - add link to ../Widgets/FlyingFader.py
dmcc
parents: 16
diff changeset
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
45b12307c695 Initial revision
drewp
parents:
diff changeset
9
45b12307c695 Initial revision
drewp
parents:
diff changeset
10 stdfont = ('Arial', 8)
45b12307c695 Initial revision
drewp
parents:
diff changeset
11 monofont = ('Courier', 8)
45b12307c695 Initial revision
drewp
parents:
diff changeset
12
45b12307c695 Initial revision
drewp
parents:
diff changeset
13 class Controlpanel(Frame):
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 23
diff changeset
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
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 23
diff changeset
16 controlpanel = self
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
17 for txt,cmd in (
45b12307c695 Initial revision
drewp
parents:
diff changeset
18 ('Quit', quit_cb),
45b12307c695 Initial revision
drewp
parents:
diff changeset
19 ('Refresh', refresh_cb),
45b12307c695 Initial revision
drewp
parents:
diff changeset
20 ('Clear all', xfader.clearallbuttons),
45b12307c695 Initial revision
drewp
parents:
diff changeset
21 ('On -> X', lambda: xfader.grab('x')),
45b12307c695 Initial revision
drewp
parents:
diff changeset
22 ('Clear X', lambda: xfader.clearallbuttons('x')),
45b12307c695 Initial revision
drewp
parents:
diff changeset
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
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 23
diff changeset
25 Button(controlpanel, text=txt, command=cmd).pack(side='top',
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 23
diff changeset
26 fill='x')
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
27
45b12307c695 Initial revision
drewp
parents:
diff changeset
28 class Console:
48
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
29 def __init__(self,refresh,currentlevels,configfilename):
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
45b12307c695 Initial revision
drewp
parents:
diff changeset
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
45b12307c695 Initial revision
drewp
parents:
diff changeset
37 self.frame.pack(fill=BOTH, expand=1)
48
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
38 self.refreshcmd=refresh
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
39 self.currentlevels=currentlevels
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
40 self.configfilename=configfilename
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
41
48
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
42 def execute(self, evt, str):
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 0
diff changeset
43 if str[0] == '*': # make a new sub
48
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
44 self.make_sub(str)
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
45 else:
45b12307c695 Initial revision
drewp
parents:
diff changeset
46 print '>>>', str
45b12307c695 Initial revision
drewp
parents:
diff changeset
47 print eval(str)
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 0
diff changeset
48 self.frame.focus()
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
49
48
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
50 def make_sub(self, name):
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
51 i = 1
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
52 if not name:
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
53 print "Enter sub name in console."
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
54 return
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
55
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
56 st = ''
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
57 linebuf = 'subs["%s"] = {' % name
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
58 for l in self.currentlevels:
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
59 if l:
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
60 if len(linebuf) > 60:
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
61 st += linebuf + '\n '
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
62 linebuf = ''
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
63
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
64 linebuf += ' "%s" : %d,' % (Patch.get_channel_name(i), l)
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
65 i += 1
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
66 st += linebuf + '}\n'
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
67 f = open(self.configfilename, 'a')
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
68 f.write(st)
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
69 f.close()
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
70 print 'Added sub:', st
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
71 self.refreshcmd()
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
72
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
73 class Leveldisplay:
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 23
diff changeset
74 def __init__(self, parent, channel_levels, num_channels=68):
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
75 frames = (make_frame(parent), make_frame(parent))
16
7dbe8067acea fixed bug with channel levels not displaying
drewp
parents: 12
diff changeset
76 channel_levels[:]=[]
34
411de8b46aef the famous you-are-in-the-process-of-changing-this-light indicator.
dmcc
parents: 32
diff changeset
77 self.number_labels = []
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 23
diff changeset
78 for channel in range(1, num_channels+1):
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 23
diff changeset
79
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 23
diff changeset
80 # frame for this channel
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 23
diff changeset
81 f = Frame(frames[channel > (num_channels/2)])
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 23
diff changeset
82 # channel number -- will turn yellow when being altered
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 23
diff changeset
83 num_lab = Label(f, text=str(channel), width=3, bg='lightPink',
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 23
diff changeset
84 font=stdfont, padx=0, pady=0, bd=0, height=1)
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 23
diff changeset
85 num_lab.pack(side='left')
34
411de8b46aef the famous you-are-in-the-process-of-changing-this-light indicator.
dmcc
parents: 32
diff changeset
86 self.number_labels.append(num_lab)
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 23
diff changeset
87
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 23
diff changeset
88 # text description of channel
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 23
diff changeset
89 Label(f, text=Patch.get_channel_name(channel), width=8,
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 23
diff changeset
90 font=stdfont, anchor='w', padx=0, pady=0, bd=0,
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 23
diff changeset
91 height=1).pack(side='left')
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 23
diff changeset
92
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 23
diff changeset
93 # current level of channel, shows intensity with color
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 23
diff changeset
94 l = Label(f, width=3, bg='lightBlue', font=stdfont, anchor='e',
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 23
diff changeset
95 padx=1, pady=0, bd=0, height=1)
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
96 l.pack(side='left')
45b12307c695 Initial revision
drewp
parents:
diff changeset
97 colorlabel(l)
45b12307c695 Initial revision
drewp
parents:
diff changeset
98 channel_levels.append(l)
45b12307c695 Initial revision
drewp
parents:
diff changeset
99 f.pack(side='top')
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 23
diff changeset
100
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 23
diff changeset
101 self.channel_levels = channel_levels
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 23
diff changeset
102 # channel_levels is an output - changelevel will use it to access
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 23
diff changeset
103 # these labels
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
104
45b12307c695 Initial revision
drewp
parents:
diff changeset
105 class Subpanels:
19
6284a812da50 makefile - add link to ../Widgets/FlyingFader.py
dmcc
parents: 16
diff changeset
106 def __init__(self, scenesparent, effectsparent, scalelevels, Subs, xfader,
38
0ce56c4dd355 small ui enhancements
drewp
parents: 34
diff changeset
107 changelevel, subediting, longestname):
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
108
45b12307c695 Initial revision
drewp
parents:
diff changeset
109 sublist = Subs.subs.items()
45b12307c695 Initial revision
drewp
parents:
diff changeset
110 sublist.sort()
45b12307c695 Initial revision
drewp
parents:
diff changeset
111
45b12307c695 Initial revision
drewp
parents:
diff changeset
112 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
113 # choose one of the sub panels to add to
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
114 if sub.is_effect:
45b12307c695 Initial revision
drewp
parents:
diff changeset
115 parent=effectsparent
30
e9d2e7754fd9 sideways subs, new x/y buttons (which don't draw right, but they work)
drewp
parents: 26
diff changeset
116 side1='bottom'
48
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
117 side2='left'
38
0ce56c4dd355 small ui enhancements
drewp
parents: 34
diff changeset
118 orient1='vert'
32
925382e7cdc8 fixed small bug with orientable
drewp
parents: 30
diff changeset
119 end1=0
925382e7cdc8 fixed small bug with orientable
drewp
parents: 30
diff changeset
120 end2=1
38
0ce56c4dd355 small ui enhancements
drewp
parents: 34
diff changeset
121 width1=len(name)
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
122 else:
45b12307c695 Initial revision
drewp
parents:
diff changeset
123 parent=scenesparent
30
e9d2e7754fd9 sideways subs, new x/y buttons (which don't draw right, but they work)
drewp
parents: 26
diff changeset
124 side1='right'
48
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
125 side2='top'
38
0ce56c4dd355 small ui enhancements
drewp
parents: 34
diff changeset
126 orient1='horiz'
32
925382e7cdc8 fixed small bug with orientable
drewp
parents: 30
diff changeset
127 end1=1
925382e7cdc8 fixed small bug with orientable
drewp
parents: 30
diff changeset
128 end2=0
38
0ce56c4dd355 small ui enhancements
drewp
parents: 34
diff changeset
129 width1=longestname
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
130
30
e9d2e7754fd9 sideways subs, new x/y buttons (which don't draw right, but they work)
drewp
parents: 26
diff changeset
131 # 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
132 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
133 f.pack(fill='both',exp=1,side=side2)
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
134
30
e9d2e7754fd9 sideways subs, new x/y buttons (which don't draw right, but they work)
drewp
parents: 26
diff changeset
135 # make DoubleVar (there might be one left around from before a refresh)
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
136 if name not in scalelevels:
45b12307c695 Initial revision
drewp
parents:
diff changeset
137 scalelevels[name]=DoubleVar()
45b12307c695 Initial revision
drewp
parents:
diff changeset
138
45b12307c695 Initial revision
drewp
parents:
diff changeset
139 sub.set_slider_var(scalelevels[name])
45b12307c695 Initial revision
drewp
parents:
diff changeset
140
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 0
diff changeset
141 scaleopts = {}
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
142 if sub.color:
45b12307c695 Initial revision
drewp
parents:
diff changeset
143 scaleopts['troughcolor'] = sub.color
19
6284a812da50 makefile - add link to ../Widgets/FlyingFader.py
dmcc
parents: 16
diff changeset
144
6284a812da50 makefile - add link to ../Widgets/FlyingFader.py
dmcc
parents: 16
diff changeset
145 s = FlyingFader(f, label=str(name), variable=scalelevels[name],
30
e9d2e7754fd9 sideways subs, new x/y buttons (which don't draw right, but they work)
drewp
parents: 26
diff changeset
146 showvalue=0, length=300-17,
e9d2e7754fd9 sideways subs, new x/y buttons (which don't draw right, but they work)
drewp
parents: 26
diff changeset
147 width=18, sliderlength=18,
32
925382e7cdc8 fixed small bug with orientable
drewp
parents: 30
diff changeset
148 to=end1,res=.001,from_=end2,bd=0, font=stdfont,
38
0ce56c4dd355 small ui enhancements
drewp
parents: 34
diff changeset
149 orient=orient1,
0ce56c4dd355 small ui enhancements
drewp
parents: 34
diff changeset
150 labelwidth=width1,
30
e9d2e7754fd9 sideways subs, new x/y buttons (which don't draw right, but they work)
drewp
parents: 26
diff changeset
151 **scaleopts)
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
152
43
2cd759c2b3c7 (21:29:34) dmcc: no need to have the E for effects
dmcc
parents: 38
diff changeset
153 if not sub.is_effect:
48
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
154 eb = Togglebutton(f,text="Edit",font=stdfont,padx=0,pady=0,bd=1,
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 43
diff changeset
155 command=lambda: subediting.setsub(sub))
43
2cd759c2b3c7 (21:29:34) dmcc: no need to have the E for effects
dmcc
parents: 38
diff changeset
156 eb.pack(side=side1,fill='both',padx=0,pady=0)
38
0ce56c4dd355 small ui enhancements
drewp
parents: 34
diff changeset
157
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 0
diff changeset
158 for axis in ('y','x'):
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 0
diff changeset
159 cvar=IntVar()
30
e9d2e7754fd9 sideways subs, new x/y buttons (which don't draw right, but they work)
drewp
parents: 26
diff changeset
160 cb=Togglebutton(f,text=axis.upper(),variable=cvar,font=stdfont, padx=0,
19
6284a812da50 makefile - add link to ../Widgets/FlyingFader.py
dmcc
parents: 16
diff changeset
161 pady=0, bd=1)
30
e9d2e7754fd9 sideways subs, new x/y buttons (which don't draw right, but they work)
drewp
parents: 26
diff changeset
162 cb.pack(side=side1,fill='both', padx=0, pady=0)
e9d2e7754fd9 sideways subs, new x/y buttons (which don't draw right, but they work)
drewp
parents: 26
diff changeset
163 s.bind('<Key-%s>'%axis, lambda ev,cb=cb: cb.invoke)
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 0
diff changeset
164 xfader.registerbutton(name,axis,cvar)
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
165
23
768442c7d023 layout fixen
dmcc
parents: 19
diff changeset
166 s.pack(side='left', fill=BOTH)
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
167
45b12307c695 Initial revision
drewp
parents:
diff changeset
168 # effects frame?
45b12307c695 Initial revision
drewp
parents:
diff changeset
169 sframe = Frame(f,bd=2,relief='groove')
45b12307c695 Initial revision
drewp
parents:
diff changeset
170 sub.draw_tk(sframe)
45b12307c695 Initial revision
drewp
parents:
diff changeset
171 sframe.pack(side='left',fill='y')