comparison 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
comparison
equal deleted inserted replaced
47:2ae11dc56b38 48:2ef72bb3a707
1 """some of the panels""" 1 """some of the panels"""
2 from __future__ import nested_scopes
2 3
3 from Tkinter import * 4 from Tkinter import *
4 from uihelpers import * 5 from uihelpers import *
5 import Patch 6 import Patch
6 from FlyingFader import FlyingFader 7 from FlyingFader import FlyingFader
23 ('Clear Y', lambda: xfader.clearallbuttons('y'))): 24 ('Clear Y', lambda: xfader.clearallbuttons('y'))):
24 Button(controlpanel, text=txt, command=cmd).pack(side='top', 25 Button(controlpanel, text=txt, command=cmd).pack(side='top',
25 fill='x') 26 fill='x')
26 27
27 class Console: 28 class Console:
28 def __init__(self): 29 def __init__(self,refresh,currentlevels,configfilename):
29 print "Light 8: Everything's under control" 30 print "Light 8: Everything's under control"
30 t=toplevelat(267,717,w=599,h=19) 31 t=toplevelat(267,717,w=599,h=19)
31 self.frame = Frame(t) 32 self.frame = Frame(t)
32 self.entry=Entry(self.frame) 33 self.entry=Entry(self.frame)
33 self.entry.pack(expand=1, fill='x') 34 self.entry.pack(expand=1, fill='x')
34 self.entry.bind('<Return>', lambda evt: self.execute(evt, 35 self.entry.bind('<Return>',
35 self.entry.get())) 36 lambda evt: self.execute(evt, self.entry.get()))
36 self.frame.pack(fill=BOTH, expand=1) 37 self.frame.pack(fill=BOTH, expand=1)
38 self.refreshcmd=refresh
39 self.currentlevels=currentlevels
40 self.configfilename=configfilename
37 41
38 def execute(evt, str): 42 def execute(self, evt, str):
39 if str[0] == '*': # make a new sub 43 if str[0] == '*': # make a new sub
40 make_sub(str) 44 self.make_sub(str)
41 else: 45 else:
42 print '>>>', str 46 print '>>>', str
43 print eval(str) 47 print eval(str)
44 self.frame.focus() 48 self.frame.focus()
49
50 def make_sub(self, name):
51 i = 1
52 if not name:
53 print "Enter sub name in console."
54 return
55
56 st = ''
57 linebuf = 'subs["%s"] = {' % name
58 for l in self.currentlevels:
59 if l:
60 if len(linebuf) > 60:
61 st += linebuf + '\n '
62 linebuf = ''
63
64 linebuf += ' "%s" : %d,' % (Patch.get_channel_name(i), l)
65 i += 1
66 st += linebuf + '}\n'
67 f = open(self.configfilename, 'a')
68 f.write(st)
69 f.close()
70 print 'Added sub:', st
71 self.refreshcmd()
45 72
46 class Leveldisplay: 73 class Leveldisplay:
47 def __init__(self, parent, channel_levels, num_channels=68): 74 def __init__(self, parent, channel_levels, num_channels=68):
48 frames = (make_frame(parent), make_frame(parent)) 75 frames = (make_frame(parent), make_frame(parent))
49 channel_levels[:]=[] 76 channel_levels[:]=[]
85 for name, sub in sublist: 112 for name, sub in sublist:
86 # choose one of the sub panels to add to 113 # choose one of the sub panels to add to
87 if sub.is_effect: 114 if sub.is_effect:
88 parent=effectsparent 115 parent=effectsparent
89 side1='bottom' 116 side1='bottom'
117 side2='left'
90 orient1='vert' 118 orient1='vert'
91 end1=0 119 end1=0
92 end2=1 120 end2=1
93 width1=len(name) 121 width1=len(name)
94 else: 122 else:
95 parent=scenesparent 123 parent=scenesparent
96 side1='right' 124 side1='right'
125 side2='top'
97 orient1='horiz' 126 orient1='horiz'
98 end1=1 127 end1=1
99 end2=0 128 end2=0
100 width1=longestname 129 width1=longestname
101 130
102 # make frame that surrounds the whole submaster 131 # make frame that surrounds the whole submaster
103 f=Frame(parent, bd=1, relief='raised') 132 f=Frame(parent, bd=1, relief='raised')
104 f.pack(fill='both',exp=1,side=('top','left')[sub.is_effect]) 133 f.pack(fill='both',exp=1,side=side2)
105 134
106 # make DoubleVar (there might be one left around from before a refresh) 135 # make DoubleVar (there might be one left around from before a refresh)
107 if name not in scalelevels: 136 if name not in scalelevels:
108 scalelevels[name]=DoubleVar() 137 scalelevels[name]=DoubleVar()
109 138
120 orient=orient1, 149 orient=orient1,
121 labelwidth=width1, 150 labelwidth=width1,
122 **scaleopts) 151 **scaleopts)
123 152
124 if not sub.is_effect: 153 if not sub.is_effect:
125 eb = Button(f,text="E",font=stdfont,padx=0,pady=0,bd=1,command=lambda subediting=subediting,sub=sub: subediting.setsub(sub)) 154 eb = Togglebutton(f,text="Edit",font=stdfont,padx=0,pady=0,bd=1,
155 command=lambda: subediting.setsub(sub))
126 eb.pack(side=side1,fill='both',padx=0,pady=0) 156 eb.pack(side=side1,fill='both',padx=0,pady=0)
127 157
128 for axis in ('y','x'): 158 for axis in ('y','x'):
129 cvar=IntVar() 159 cvar=IntVar()
130 cb=Togglebutton(f,text=axis.upper(),variable=cvar,font=stdfont, padx=0, 160 cb=Togglebutton(f,text=axis.upper(),variable=cvar,font=stdfont, padx=0,