annotate flax/KeyboardComposer.py @ 148:d6252880a6fc

after the mega merge -- now has a dummy mode
author dmcc
date Sun, 06 Jul 2003 14:05:33 +0000
parents 4041eefed719
children 79bc84310e80
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
1 from __future__ import nested_scopes
136
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
2 import sys, time
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
3 sys.path.append('..')
45b12307c695 Initial revision
drewp
parents:
diff changeset
4 from Widgets.Fadable import Fadable
45b12307c695 Initial revision
drewp
parents:
diff changeset
5
45b12307c695 Initial revision
drewp
parents:
diff changeset
6 from Tix import *
136
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
7 import math, atexit, pickle
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
8 from Submaster import Submasters, sub_maxes
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
9 import dmxclient
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
10 from uihelpers import toplevelat
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
11
45b12307c695 Initial revision
drewp
parents:
diff changeset
12 nudge_keys = {
45b12307c695 Initial revision
drewp
parents:
diff changeset
13 'up' : list('qwertyuiop'),
45b12307c695 Initial revision
drewp
parents:
diff changeset
14 'down' : list('asdfghjkl')
45b12307c695 Initial revision
drewp
parents:
diff changeset
15 }
45b12307c695 Initial revision
drewp
parents:
diff changeset
16 nudge_keys['down'].append('semicolon')
45b12307c695 Initial revision
drewp
parents:
diff changeset
17
45b12307c695 Initial revision
drewp
parents:
diff changeset
18 class SubScale(Scale, Fadable):
45b12307c695 Initial revision
drewp
parents:
diff changeset
19 def __init__(self, master, *args, **kw):
45b12307c695 Initial revision
drewp
parents:
diff changeset
20 self.scale_var = kw.get('variable') or DoubleVar()
45b12307c695 Initial revision
drewp
parents:
diff changeset
21 kw.update({'variable' : self.scale_var,
136
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
22 'from' : 1, 'to' : 0, 'showvalue' : 0,
146
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
23 'sliderlength' : 15, 'res' : 0.01,
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
24 'width' : 40, 'troughcolor' : 'black', 'bg' : 'grey40',
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
25 'highlightthickness' : 1, 'bd' : 1,
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
26 'highlightcolor' : 'red', 'highlightbackground' : 'black',
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
27 'activebackground' : 'red'})
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
28 Scale.__init__(self, master, *args, **kw)
136
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
29 Fadable.__init__(self, var=self.scale_var, wheel_step=0.05)
146
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
30 self.draw_indicator_colors()
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
31 def draw_indicator_colors(self):
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
32 if self.scale_var.get() == 0:
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
33 self['troughcolor'] = 'black'
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
34 else:
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
35 self['troughcolor'] = 'blue'
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
36
45b12307c695 Initial revision
drewp
parents:
diff changeset
37 class SubmasterTk(Frame):
45b12307c695 Initial revision
drewp
parents:
diff changeset
38 def __init__(self, master, name, current_level):
146
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
39 Frame.__init__(self, master, bd=1, relief='raised', bg='black')
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
40 self.slider_var = DoubleVar()
45b12307c695 Initial revision
drewp
parents:
diff changeset
41 self.slider_var.set(current_level)
45b12307c695 Initial revision
drewp
parents:
diff changeset
42 self.scale = SubScale(self, variable=self.slider_var, width=20)
146
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
43 namelabel = Label(self, text=name, font="Arial 8", bg='black',
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
44 fg='white')
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
45 namelabel.pack(side=TOP)
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
46 levellabel = Label(self, textvariable=self.slider_var, font="Arial 8",
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
47 bg='black', fg='white')
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
48 levellabel.pack(side=TOP)
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
49 self.scale.pack(side=BOTTOM, expand=1, fill=BOTH)
45b12307c695 Initial revision
drewp
parents:
diff changeset
50
45b12307c695 Initial revision
drewp
parents:
diff changeset
51 class KeyboardComposer(Frame):
148
d6252880a6fc after the mega merge -- now has a dummy mode
dmcc
parents: 146
diff changeset
52 def __init__(self, root, submasters, current_sub_levels=None, dmxdummy=0):
146
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
53 Frame.__init__(self, root, bg='black')
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
54 self.submasters = submasters
148
d6252880a6fc after the mega merge -- now has a dummy mode
dmcc
parents: 146
diff changeset
55 self.dmxdummy = dmxdummy
d6252880a6fc after the mega merge -- now has a dummy mode
dmcc
parents: 146
diff changeset
56
136
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
57 self.current_sub_levels = {}
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
58 if current_sub_levels:
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
59 self.current_sub_levels = current_sub_levels
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
60 else:
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
61 try:
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
62 self.current_sub_levels = \
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
63 pickle.load(file('.keyboardcomposer.savedlevels'))
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
64 except IOError:
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
65 pass
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
66
136
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
67 self.draw_ui()
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
68 self.send_levels_loop()
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
69 def draw_ui(self):
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
70 self.rows = [] # this holds Tk Frames for each row
45b12307c695 Initial revision
drewp
parents:
diff changeset
71 self.slider_vars = {} # this holds subname:sub Tk vars
45b12307c695 Initial revision
drewp
parents:
diff changeset
72 self.slider_table = {} # this holds coords:sub Tk vars
45b12307c695 Initial revision
drewp
parents:
diff changeset
73 self.current_row = 0
45b12307c695 Initial revision
drewp
parents:
diff changeset
74
45b12307c695 Initial revision
drewp
parents:
diff changeset
75 self.make_key_hints()
45b12307c695 Initial revision
drewp
parents:
diff changeset
76 self.draw_sliders()
45b12307c695 Initial revision
drewp
parents:
diff changeset
77 self.highlight_row(self.current_row)
45b12307c695 Initial revision
drewp
parents:
diff changeset
78 self.rows[self.current_row].focus()
136
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
79
146
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
80 self.buttonframe = Frame(self, bg='black')
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
81 self.buttonframe.pack(side=BOTTOM)
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
82 self.refreshbutton = Button(self.buttonframe, text="Refresh",
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
83 command=self.refresh, bg='black', fg='white')
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
84 self.refreshbutton.pack(side=LEFT)
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
85 self.save_stage_button = Button(self.buttonframe, text="Save",
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
86 command=lambda: self.save_current_stage(self.sub_name.get()),
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
87 bg='black', fg='white')
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
88 self.save_stage_button.pack(side=LEFT)
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
89 self.sub_name = Entry(self.buttonframe, bg='black', fg='white')
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
90 self.sub_name.pack(side=LEFT)
136
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
91 self.stop_frequent_update_time = 0
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
92 def make_key_hints(self):
45b12307c695 Initial revision
drewp
parents:
diff changeset
93 keyhintrow = Frame(self)
45b12307c695 Initial revision
drewp
parents:
diff changeset
94
45b12307c695 Initial revision
drewp
parents:
diff changeset
95 col = 0
45b12307c695 Initial revision
drewp
parents:
diff changeset
96 for upkey, downkey in zip(nudge_keys['up'],
45b12307c695 Initial revision
drewp
parents:
diff changeset
97 nudge_keys['down']):
45b12307c695 Initial revision
drewp
parents:
diff changeset
98 # what a hack!
45b12307c695 Initial revision
drewp
parents:
diff changeset
99 downkey = downkey.replace('semicolon', ';')
136
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
100 upkey, downkey = (upkey.upper(), downkey.upper())
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
101
45b12307c695 Initial revision
drewp
parents:
diff changeset
102 # another what a hack!
45b12307c695 Initial revision
drewp
parents:
diff changeset
103 keylabel = Label(keyhintrow, text='%s\n%s' % (upkey, downkey),
146
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
104 width=1, font=('Arial', 10), bg='red', fg='white', anchor='c')
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
105 keylabel.pack(side=LEFT, expand=1, fill=X)
45b12307c695 Initial revision
drewp
parents:
diff changeset
106 col += 1
45b12307c695 Initial revision
drewp
parents:
diff changeset
107
45b12307c695 Initial revision
drewp
parents:
diff changeset
108 keyhintrow.pack(fill=X, expand=0)
45b12307c695 Initial revision
drewp
parents:
diff changeset
109 self.keyhints = keyhintrow
45b12307c695 Initial revision
drewp
parents:
diff changeset
110 def setup_key_nudgers(self, tkobject):
45b12307c695 Initial revision
drewp
parents:
diff changeset
111 for d, keys in nudge_keys.items():
45b12307c695 Initial revision
drewp
parents:
diff changeset
112 for key in keys:
45b12307c695 Initial revision
drewp
parents:
diff changeset
113 # lowercase makes full=0
45b12307c695 Initial revision
drewp
parents:
diff changeset
114 keysym = "<KeyPress-%s>" % key
45b12307c695 Initial revision
drewp
parents:
diff changeset
115 tkobject.bind(keysym, \
45b12307c695 Initial revision
drewp
parents:
diff changeset
116 lambda evt, num=keys.index(key), d=d: \
45b12307c695 Initial revision
drewp
parents:
diff changeset
117 self.got_nudger(num, d))
45b12307c695 Initial revision
drewp
parents:
diff changeset
118
45b12307c695 Initial revision
drewp
parents:
diff changeset
119 # uppercase makes full=1
45b12307c695 Initial revision
drewp
parents:
diff changeset
120 keysym = "<KeyPress-%s>" % key.upper()
45b12307c695 Initial revision
drewp
parents:
diff changeset
121 keysym = keysym.replace('SEMICOLON', 'colon')
45b12307c695 Initial revision
drewp
parents:
diff changeset
122 tkobject.bind(keysym, \
45b12307c695 Initial revision
drewp
parents:
diff changeset
123 lambda evt, num=keys.index(key), d=d: \
45b12307c695 Initial revision
drewp
parents:
diff changeset
124 self.got_nudger(num, d, full=1))
45b12307c695 Initial revision
drewp
parents:
diff changeset
125
45b12307c695 Initial revision
drewp
parents:
diff changeset
126 # page up and page down change the row
45b12307c695 Initial revision
drewp
parents:
diff changeset
127 for key in '<Prior> <Next> <Control-n> <Control-p>'.split():
45b12307c695 Initial revision
drewp
parents:
diff changeset
128 tkobject.bind(key, self.change_row)
45b12307c695 Initial revision
drewp
parents:
diff changeset
129
45b12307c695 Initial revision
drewp
parents:
diff changeset
130 def change_row(self, event):
45b12307c695 Initial revision
drewp
parents:
diff changeset
131 diff = 1
146
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
132 if event.keysym in ('Prior', 'p'):
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
133 diff = -1
45b12307c695 Initial revision
drewp
parents:
diff changeset
134 old_row = self.current_row
45b12307c695 Initial revision
drewp
parents:
diff changeset
135 self.current_row += diff
45b12307c695 Initial revision
drewp
parents:
diff changeset
136 self.current_row = max(0, self.current_row)
45b12307c695 Initial revision
drewp
parents:
diff changeset
137 self.current_row = min(len(self.rows) - 1, self.current_row)
45b12307c695 Initial revision
drewp
parents:
diff changeset
138 self.unhighlight_row(old_row)
45b12307c695 Initial revision
drewp
parents:
diff changeset
139 self.highlight_row(self.current_row)
45b12307c695 Initial revision
drewp
parents:
diff changeset
140 row = self.rows[self.current_row]
45b12307c695 Initial revision
drewp
parents:
diff changeset
141 self.keyhints.pack_configure(before=row)
45b12307c695 Initial revision
drewp
parents:
diff changeset
142 def got_nudger(self, number, direction, full=0):
45b12307c695 Initial revision
drewp
parents:
diff changeset
143 subtk = self.slider_table[(self.current_row, number)]
45b12307c695 Initial revision
drewp
parents:
diff changeset
144 if direction == 'up':
45b12307c695 Initial revision
drewp
parents:
diff changeset
145 if full:
136
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
146 subtk.scale.fade(1)
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
147 else:
45b12307c695 Initial revision
drewp
parents:
diff changeset
148 subtk.scale.increase()
45b12307c695 Initial revision
drewp
parents:
diff changeset
149 else:
45b12307c695 Initial revision
drewp
parents:
diff changeset
150 if full:
45b12307c695 Initial revision
drewp
parents:
diff changeset
151 subtk.scale.fade(0)
45b12307c695 Initial revision
drewp
parents:
diff changeset
152 else:
45b12307c695 Initial revision
drewp
parents:
diff changeset
153 subtk.scale.decrease()
45b12307c695 Initial revision
drewp
parents:
diff changeset
154 def draw_sliders(self):
45b12307c695 Initial revision
drewp
parents:
diff changeset
155 self.tk_focusFollowsMouse()
45b12307c695 Initial revision
drewp
parents:
diff changeset
156
45b12307c695 Initial revision
drewp
parents:
diff changeset
157 rowcount = -1
45b12307c695 Initial revision
drewp
parents:
diff changeset
158 col = 0
136
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
159 for sub in self.submasters.get_all_subs():
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
160 if col == 0: # make new row
45b12307c695 Initial revision
drewp
parents:
diff changeset
161 row = self.make_row()
45b12307c695 Initial revision
drewp
parents:
diff changeset
162 rowcount += 1
45b12307c695 Initial revision
drewp
parents:
diff changeset
163 current_level = self.current_sub_levels.get(sub.name, 0)
45b12307c695 Initial revision
drewp
parents:
diff changeset
164 subtk = self.draw_sub_slider(row, col, sub.name, current_level)
45b12307c695 Initial revision
drewp
parents:
diff changeset
165 self.slider_table[(rowcount, col)] = subtk
45b12307c695 Initial revision
drewp
parents:
diff changeset
166 col += 1
45b12307c695 Initial revision
drewp
parents:
diff changeset
167 col %= 10
136
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
168
146
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
169 def slider_changed(x, y, z, subtk=subtk):
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
170 subtk.scale.draw_indicator_colors()
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
171 self.send_levels()
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
172
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
173 subtk.slider_var.trace('w', slider_changed)
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
174 def make_row(self):
146
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
175 row = Frame(self, bd=2, bg='black')
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
176 row.pack(expand=1, fill=BOTH)
45b12307c695 Initial revision
drewp
parents:
diff changeset
177 self.setup_key_nudgers(row)
45b12307c695 Initial revision
drewp
parents:
diff changeset
178 self.rows.append(row)
45b12307c695 Initial revision
drewp
parents:
diff changeset
179 return row
45b12307c695 Initial revision
drewp
parents:
diff changeset
180 def draw_sub_slider(self, row, col, name, current_level):
45b12307c695 Initial revision
drewp
parents:
diff changeset
181 subtk = SubmasterTk(row, name, current_level)
45b12307c695 Initial revision
drewp
parents:
diff changeset
182 subtk.place(relx=col * 0.1, rely=0, relwidth=0.1, relheight=1)
45b12307c695 Initial revision
drewp
parents:
diff changeset
183 self.setup_key_nudgers(subtk.scale)
45b12307c695 Initial revision
drewp
parents:
diff changeset
184
45b12307c695 Initial revision
drewp
parents:
diff changeset
185 self.slider_vars[name] = subtk.slider_var
45b12307c695 Initial revision
drewp
parents:
diff changeset
186 return subtk
45b12307c695 Initial revision
drewp
parents:
diff changeset
187 def highlight_row(self, row):
45b12307c695 Initial revision
drewp
parents:
diff changeset
188 row = self.rows[row]
45b12307c695 Initial revision
drewp
parents:
diff changeset
189 row['bg'] = 'red'
45b12307c695 Initial revision
drewp
parents:
diff changeset
190 def unhighlight_row(self, row):
45b12307c695 Initial revision
drewp
parents:
diff changeset
191 row = self.rows[row]
146
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
192 row['bg'] = 'black'
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
193 def get_levels(self):
45b12307c695 Initial revision
drewp
parents:
diff changeset
194 return dict([(name, slidervar.get())
45b12307c695 Initial revision
drewp
parents:
diff changeset
195 for name, slidervar in self.slider_vars.items()])
146
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
196 def get_levels_as_sub(self):
136
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
197 scaledsubs = [self.submasters.get_sub_by_name(sub) * level \
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
198 for sub, level in self.get_levels().items()]
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
199
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
200 maxes = sub_maxes(*scaledsubs)
146
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
201 return maxes
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
202 def save_current_stage(self, subname):
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
203 print "saving current levels as", subname
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
204 sub = self.get_levels_as_sub()
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
205 sub.name = subname
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
206 sub.save()
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
207
136
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
208 def save(self):
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
209 pickle.dump(self.get_levels(),
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
210 file('.keyboardcomposer.savedlevels', 'w'))
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
211 def send_frequent_updates(self):
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
212 """called when we get a fade -- send events as quickly as possible"""
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
213 if time.time() <= self.stop_frequent_update_time:
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
214 self.send_levels()
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
215 self.after(10, self.send_frequent_updates)
146
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
216
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
217 def get_dmx_list(self):
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
218 maxes = self.get_levels_as_sub()
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
219 return maxes.get_dmx_list()
136
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
220 def send_levels(self):
148
d6252880a6fc after the mega merge -- now has a dummy mode
dmcc
parents: 146
diff changeset
221 if not self.dmxdummy:
d6252880a6fc after the mega merge -- now has a dummy mode
dmcc
parents: 146
diff changeset
222 levels = self.get_dmx_list()
d6252880a6fc after the mega merge -- now has a dummy mode
dmcc
parents: 146
diff changeset
223 dmxclient.outputlevels(levels)
138
304152488ed7 Timeline: new methods to make editing easier
dmcc
parents: 136
diff changeset
224 # print "sending levels", levels
136
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
225 def send_levels_loop(self):
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
226 self.send_levels()
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
227 self.after(1000, self.send_levels_loop)
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
228 def refresh(self):
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
229 self.save()
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
230 self.submasters = Submasters()
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
231 self.current_sub_levels = \
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
232 pickle.load(file('.keyboardcomposer.savedlevels'))
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
233 for r in self.rows:
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
234 r.destroy()
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
235 self.keyhints.destroy()
146
4041eefed719 many changes from the theater. mostly color effects
drewp
parents: 139
diff changeset
236 self.buttonframe.destroy()
136
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
237 self.draw_ui()
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
238
45b12307c695 Initial revision
drewp
parents:
diff changeset
239 if __name__ == "__main__":
136
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
240 s = Submasters()
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
241
45b12307c695 Initial revision
drewp
parents:
diff changeset
242 root = Tk()
136
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
243 tl = toplevelat("Keyboard Composer", existingtoplevel=root)
148
d6252880a6fc after the mega merge -- now has a dummy mode
dmcc
parents: 146
diff changeset
244 kc = KeyboardComposer(tl, s, dmxdummy=1)
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
245 kc.pack(fill=BOTH, expand=1)
136
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
246 atexit.register(kc.save)
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
247 try:
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
248 mainloop()
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
249 except KeyboardInterrupt:
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
250 tl.destroy()
7e91c49fb2d6 whoops, forgot this one
dmcc
parents: 122
diff changeset
251 sys.exit()