annotate light8/rsn.py @ 53:032b2b67bc10

result of July 7th on-site editing
author dmcc
date Mon, 08 Jul 2002 14:31:20 +0000
parents 71489bb71528
children 3011c1028eb7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
1 #!/usr/bin/env python
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
2 from __future__ import nested_scopes
45b12307c695 Initial revision
drewp
parents:
diff changeset
3
51
71489bb71528 - Meet Fader. He is going to grow up and be a crossfader some day
dmcc
parents: 49
diff changeset
4 from Tix import *
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
5 from time import sleep
35
3cbe7110d8f7 cleanup imports, fix backwards colors in changing level direction
dmcc
parents: 34
diff changeset
6 from signal import signal, SIGINT
3cbe7110d8f7 cleanup imports, fix backwards colors in changing level direction
dmcc
parents: 34
diff changeset
7 import sys, cPickle
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
8
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
9 import io
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
10 from uihelpers import *
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
11 from panels import *
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
12 from Xfader import *
39
2443de5df9c5 added subeditor
drewp
parents: 35
diff changeset
13 from subediting import Subediting
51
71489bb71528 - Meet Fader. He is going to grow up and be a crossfader some day
dmcc
parents: 49
diff changeset
14 from Fader import Fader
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
15 import stage
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
16
51
71489bb71528 - Meet Fader. He is going to grow up and be a crossfader some day
dmcc
parents: 49
diff changeset
17
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
18 if len(sys.argv) >= 2:
45b12307c695 Initial revision
drewp
parents:
diff changeset
19 DUMMY = 0
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
20 print "This is the real thing, baby"
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
21 window_title = "Light 8.8 (On Air)"
45b12307c695 Initial revision
drewp
parents:
diff changeset
22 else:
45b12307c695 Initial revision
drewp
parents:
diff changeset
23 DUMMY = 1
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
24 print "Dummy mode"
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
25 window_title = "Light 8.8 (Bogus)"
45b12307c695 Initial revision
drewp
parents:
diff changeset
26
45b12307c695 Initial revision
drewp
parents:
diff changeset
27 root = Tk()
45b12307c695 Initial revision
drewp
parents:
diff changeset
28 root.wm_title(window_title)
30
e9d2e7754fd9 sideways subs, new x/y buttons (which don't draw right, but they work)
drewp
parents: 29
diff changeset
29 root.wm_geometry('+462+470')
19
6284a812da50 makefile - add link to ../Widgets/FlyingFader.py
dmcc
parents: 17
diff changeset
30 root.tk_focusFollowsMouse()
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
31
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
32 import Subs, Patch
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
33
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
34 def get_data(*args):
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
35 Subs.reload_data(DUMMY)
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
36 Patch.reload_data(DUMMY)
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
37 print "Patch:", Patch.patch
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
38 print "Subs:", ', '.join(Subs.subs.keys())
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
39
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
40 get_data()
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
41
29
f595fdd4c548 minor cleanups, convert parallel port controller to a class
dmcc
parents: 28
diff changeset
42 parportdmx = io.ParportDMX(DUMMY)
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
43
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
44 class Lightboard:
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
45 def __init__(self, master):
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
46 self.master = master
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
47
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
48 self.channel_levels = []
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
49 self.scalelevels = {}
39
2443de5df9c5 added subeditor
drewp
parents: 35
diff changeset
50 self.xfader = Xfader(self.scalelevels) # doesn't draw any UI yet-- look for self.xfader.setupwidget()
48
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 39
diff changeset
51 self.oldlevels = [None] * 68 # never replace this; just clear it
39
2443de5df9c5 added subeditor
drewp
parents: 35
diff changeset
52 self.subediting = Subediting(currentoutputlevels=self.oldlevels)
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
53
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
54 self.buildinterface()
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
55 self.load()
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
56 self.backgroundloop()
39
2443de5df9c5 added subeditor
drewp
parents: 35
diff changeset
57
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
58 def buildinterface(self):
48
2ef72bb3a707 finished the re-class of Console so it can make new subs again
drewp
parents: 39
diff changeset
59 global DUMMY
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
60 for w in self.master.winfo_children():
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
61 w.destroy()
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
62
53
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
63 stage_tl = toplevelat(22,30)
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
64 s = stage.Stage(stage_tl)
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
65 stage.createlights(s)
39
2443de5df9c5 added subeditor
drewp
parents: 35
diff changeset
66 s.setsubediting(self.subediting)
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
67 s.pack()
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
68
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
69 sub_tl = toplevelat(0,0)
30
e9d2e7754fd9 sideways subs, new x/y buttons (which don't draw right, but they work)
drewp
parents: 29
diff changeset
70 effect_tl = toplevelat(462,4)
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
71
53
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
72 self.subpanels = Subpanels(sub_tl, effect_tl, self, self.scalelevels,
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
73 Subs, self.xfader, self.changelevel,
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
74 self.subediting, Subs.longestsubname())
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
75
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
76 leveldisplay_tl = toplevelat(873,400)
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
77 leveldisplay_tl.bind('<Escape>', sys.exit)
16
7dbe8067acea fixed bug with channel levels not displaying
drewp
parents: 12
diff changeset
78
34
411de8b46aef the famous you-are-in-the-process-of-changing-this-light indicator.
dmcc
parents: 33
diff changeset
79 self.leveldisplay = Leveldisplay(leveldisplay_tl, self.channel_levels)
49
f734762c1d34 fixed bug where leveldisplay would appear empty after refresh
drewp
parents: 48
diff changeset
80 for i in range(0,len(self.channel_levels)):
f734762c1d34 fixed bug where leveldisplay would appear empty after refresh
drewp
parents: 48
diff changeset
81 self.channel_levels[i].config(text=self.oldlevels[i])
53
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
82 colorlabel(self.channel_levels[i])
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
83
53
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
84 Console(self)
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
85
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
86 # root frame
33
d9a0f6c88b39 Fix bad refs to quit
dmcc
parents: 30
diff changeset
87 controlpanel = Controlpanel(root, self.xfader, self.refresh, self.quit)
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
88
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
89 xf=Frame(root)
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
90 xf.pack(side='right')
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
91
33
d9a0f6c88b39 Fix bad refs to quit
dmcc
parents: 30
diff changeset
92 root.bind('<q>', self.quit)
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
93 root.bind('<r>', self.refresh)
33
d9a0f6c88b39 Fix bad refs to quit
dmcc
parents: 30
diff changeset
94 leveldisplay_tl.bind('<q>', self.quit)
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
95 leveldisplay_tl.bind('<r>', self.refresh)
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
96
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
97 self.xfader.setupwidget(xf)
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
98 controlpanel.pack()
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
99
53
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
100 # cuefader_tl = toplevelat(98, 480)
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
101 # cuefader = Fader(cuefader_tl, Subs.cues, self.scalelevels)
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
102 # cuefader.pack()
51
71489bb71528 - Meet Fader. He is going to grow up and be a crossfader some day
dmcc
parents: 49
diff changeset
103
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
104 def refresh(self, *args):
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
105 'rebuild interface, reload data'
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
106 get_data()
53
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
107 self.subediting.refresh()
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
108 self.buildinterface()
33
d9a0f6c88b39 Fix bad refs to quit
dmcc
parents: 30
diff changeset
109 bindkeys(root,'<Escape>', self.quit)
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
110
53
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
111 def stageassub(self):
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
112 """returns the current onstage lighting as a levels
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
113 dictionary, skipping the zeros, and using names where
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
114 possible"""
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
115 levs=self.oldlevels
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
116
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
117 return dict([(Patch.get_channel_name(i),l) for i,l
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
118 in zip(range(1,len(levs)+1),levs)
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
119 if l>0])
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
120 def save_sub(self, name, levels):
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
121 if not name:
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
122 print "Enter sub name in console."
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
123 return
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
124
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
125 st = ''
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
126 linebuf = 'subs["%s"] = {' % name
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
127 for channame,lev in levels.items():
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
128 if len(linebuf) > 60:
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
129 st += linebuf + '\n '
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
130 linebuf = ''
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
131
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
132 linebuf += ' "%s" : %d,' % (channame, lev)
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
133 st += linebuf + '}\n'
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
134 if DUMMY:
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
135 filename = 'ConfigDummy.py'
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
136 else:
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
137 filename = 'Config.py'
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
138 f = open(filename, 'a')
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
139 f.write(st)
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
140 f.close()
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
141 print 'Added sub:', st
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
142 self.refresh()
032b2b67bc10 result of July 7th on-site editing
dmcc
parents: 51
diff changeset
143
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
144 # this is called on a loop, and ALSO by the Scales
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
145 def changelevel(self, *args):
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
146 'Amp trims slider'
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
147
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
148 levels = [0] * 68
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
149 for name, s in Subs.subs.items():
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
150 newlevels = s.get_levels(level=self.scalelevels[name].get())
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
151 for (ch, fadelev) in newlevels.items():
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
152 levels[ch-1] = max(levels[ch-1], fadelev)
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
153
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
154 levels = [int(l) for l in levels]
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
155
34
411de8b46aef the famous you-are-in-the-process-of-changing-this-light indicator.
dmcc
parents: 33
diff changeset
156 for lev,lab,oldlev,numlab in zip(levels, self.channel_levels,
411de8b46aef the famous you-are-in-the-process-of-changing-this-light indicator.
dmcc
parents: 33
diff changeset
157 self.oldlevels,
411de8b46aef the famous you-are-in-the-process-of-changing-this-light indicator.
dmcc
parents: 33
diff changeset
158 self.leveldisplay.number_labels):
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
159 if lev != oldlev:
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
160 lab.config(text="%d" % lev)
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
161 colorlabel(lab)
34
411de8b46aef the famous you-are-in-the-process-of-changing-this-light indicator.
dmcc
parents: 33
diff changeset
162 if lev < oldlev:
35
3cbe7110d8f7 cleanup imports, fix backwards colors in changing level direction
dmcc
parents: 34
diff changeset
163 numlab['bg'] = 'blue'
34
411de8b46aef the famous you-are-in-the-process-of-changing-this-light indicator.
dmcc
parents: 33
diff changeset
164 else:
35
3cbe7110d8f7 cleanup imports, fix backwards colors in changing level direction
dmcc
parents: 34
diff changeset
165 numlab['bg'] = 'red'
34
411de8b46aef the famous you-are-in-the-process-of-changing-this-light indicator.
dmcc
parents: 33
diff changeset
166 else:
411de8b46aef the famous you-are-in-the-process-of-changing-this-light indicator.
dmcc
parents: 33
diff changeset
167 numlab['bg'] = 'lightPink'
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
168
39
2443de5df9c5 added subeditor
drewp
parents: 35
diff changeset
169 self.oldlevels[:] = levels[:] # replace the elements in oldlevels - don't make a new list (Subediting is watching it)
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
170
29
f595fdd4c548 minor cleanups, convert parallel port controller to a class
dmcc
parents: 28
diff changeset
171 parportdmx.sendlevels(levels)
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
172
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
173 def load(self):
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
174 try:
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
175 filename = '/tmp/light9.prefs'
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
176 if DUMMY:
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
177 filename += '.dummy'
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
178 print "Loading from", filename
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
179 file = open(filename, 'r')
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
180 p = cPickle.load(file)
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
181 for s, v in p.scalelevels.items():
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
182 try:
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
183 self.scalelevels[s].set(v)
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
184 except:
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
185 print "Couldn't set %s -> %s" % (s, v)
28
b0342f9ee328 attempts to save params, better loading behavior
dmcc
parents: 26
diff changeset
186 for name, substate in p.substate.items():
b0342f9ee328 attempts to save params, better loading behavior
dmcc
parents: 26
diff changeset
187 try:
b0342f9ee328 attempts to save params, better loading behavior
dmcc
parents: 26
diff changeset
188 Subs.subs[name].set_state(substate)
b0342f9ee328 attempts to save params, better loading behavior
dmcc
parents: 26
diff changeset
189 except:
b0342f9ee328 attempts to save params, better loading behavior
dmcc
parents: 26
diff changeset
190 print "Couldn't set sub %s state" % name
b0342f9ee328 attempts to save params, better loading behavior
dmcc
parents: 26
diff changeset
191 except IOError:
b0342f9ee328 attempts to save params, better loading behavior
dmcc
parents: 26
diff changeset
192 print "IOError: Couldn't load prefs (%s)" % filename
b0342f9ee328 attempts to save params, better loading behavior
dmcc
parents: 26
diff changeset
193 except EOFError:
b0342f9ee328 attempts to save params, better loading behavior
dmcc
parents: 26
diff changeset
194 print "EOFrror: Couldn't load prefs (%s)" % filename
29
f595fdd4c548 minor cleanups, convert parallel port controller to a class
dmcc
parents: 28
diff changeset
195 except:
f595fdd4c548 minor cleanups, convert parallel port controller to a class
dmcc
parents: 28
diff changeset
196 print "BigTrouble: Couldn't load prefs (%s)" % filename
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
197
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
198 def backgroundloop(self, *args):
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
199 self.master.after(50, self.backgroundloop, ())
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
200 self.changelevel()
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
201 def quit(self, *args):
28
b0342f9ee328 attempts to save params, better loading behavior
dmcc
parents: 26
diff changeset
202 self.save()
b0342f9ee328 attempts to save params, better loading behavior
dmcc
parents: 26
diff changeset
203 root.destroy()
b0342f9ee328 attempts to save params, better loading behavior
dmcc
parents: 26
diff changeset
204 sys.exit()
b0342f9ee328 attempts to save params, better loading behavior
dmcc
parents: 26
diff changeset
205 def save(self, *args):
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
206 filename = '/tmp/light9.prefs'
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
207 if DUMMY:
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
208 filename += '.dummy'
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
209 print "Saving to", filename
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
210 file = open(filename, 'w')
28
b0342f9ee328 attempts to save params, better loading behavior
dmcc
parents: 26
diff changeset
211 try:
b0342f9ee328 attempts to save params, better loading behavior
dmcc
parents: 26
diff changeset
212 cPickle.dump(Pickles(self.scalelevels, Subs.subs.items()), file)
b0342f9ee328 attempts to save params, better loading behavior
dmcc
parents: 26
diff changeset
213 except cPickle.UnpickleableError:
b0342f9ee328 attempts to save params, better loading behavior
dmcc
parents: 26
diff changeset
214 print "UnpickleableError! There's yer problem."
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
215
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
216 class Pickles:
28
b0342f9ee328 attempts to save params, better loading behavior
dmcc
parents: 26
diff changeset
217 def __init__(self, scalelevels, subs=None):
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
218 self.scalelevels = dict([(name, lev.get())
28
b0342f9ee328 attempts to save params, better loading behavior
dmcc
parents: 26
diff changeset
219 for name, lev in scalelevels.items()])
b0342f9ee328 attempts to save params, better loading behavior
dmcc
parents: 26
diff changeset
220 self.substate = dict([(name, subobj.get_state())
b0342f9ee328 attempts to save params, better loading behavior
dmcc
parents: 26
diff changeset
221 for name, subobj in subs])
29
f595fdd4c548 minor cleanups, convert parallel port controller to a class
dmcc
parents: 28
diff changeset
222 # print "substate", self.substate
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
223
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
224 mr_lightboard = Lightboard(root)
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
225
26
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
226 signal(SIGINT, mr_lightboard.quit)
219d6fcbc28d Reclassification, minor cleanups
dmcc
parents: 19
diff changeset
227 bindkeys(root,'<Escape>', mr_lightboard.quit)
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
228
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
229 root.mainloop() # Receiver switches main