Mercurial > code > home > repos > light9
annotate bin/keyboardcomposer @ 343:fe9dff7dbffd
added C-l to launch subcomposer- in progress
keyboardcomposer will probably launch subcomposer correctly,
but i don't even know if KC blocks or not (untested), and
the SC is certainly a child process of the KC, which is
undesirable. We think that some sort of setpgrp call in
the child may fix that.
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Mon, 19 Jun 2006 02:20:41 +0000 |
parents | 5322639d61e9 |
children | c7478a778992 |
rev | line source |
---|---|
214 | 1 #!/usr/bin/python |
2 | |
268
d5858e9fa689
keyboardcomposer destroy fix and cleanups
David McClosky <dmcc@bigasterisk.com>
parents:
264
diff
changeset
|
3 from __future__ import division, nested_scopes |
343
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
4 import os, sys, time, subprocess |
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
5 from optparse import OptionParser |
0 | 6 |
268
d5858e9fa689
keyboardcomposer destroy fix and cleanups
David McClosky <dmcc@bigasterisk.com>
parents:
264
diff
changeset
|
7 from twisted.internet import reactor, tksupport |
205
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
8 from twisted.web import xmlrpc, server |
0 | 9 from Tix import * |
343
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
10 import Tix as tk |
253
a92b6d1ac072
SubClient created, keyboardcomposer and gyrocontroller use it now
David McClosky <dmcc@bigasterisk.com>
parents:
246
diff
changeset
|
11 import pickle |
214 | 12 |
13 import run_local | |
14 from light9.Fadable import Fadable | |
15 from light9.Submaster import Submasters, sub_maxes | |
260
7f9d0f04bb2d
KeyboardComposer is now a SubClient
David McClosky <dmcc@bigasterisk.com>
parents:
253
diff
changeset
|
16 from light9.subclient import SubClient |
270
54774cba50c9
revive kcclient and fix subcomposer so kcclient works through refreshes
Drew Perttula <drewp@bigasterisk.com>
parents:
268
diff
changeset
|
17 from light9 import dmxclient, showconfig, networking |
343
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
18 from light9.uihelpers import toplevelat, bindkeys |
0 | 19 |
20 nudge_keys = { | |
21 'up' : list('qwertyuiop'), | |
22 'down' : list('asdfghjkl') | |
23 } | |
24 nudge_keys['down'].append('semicolon') | |
25 | |
26 class SubScale(Scale, Fadable): | |
27 def __init__(self, master, *args, **kw): | |
28 self.scale_var = kw.get('variable') or DoubleVar() | |
29 kw.update({'variable' : self.scale_var, | |
136 | 30 'from' : 1, 'to' : 0, 'showvalue' : 0, |
146 | 31 'sliderlength' : 15, 'res' : 0.01, |
32 'width' : 40, 'troughcolor' : 'black', 'bg' : 'grey40', | |
33 'highlightthickness' : 1, 'bd' : 1, | |
34 'highlightcolor' : 'red', 'highlightbackground' : 'black', | |
35 'activebackground' : 'red'}) | |
0 | 36 Scale.__init__(self, master, *args, **kw) |
136 | 37 Fadable.__init__(self, var=self.scale_var, wheel_step=0.05) |
146 | 38 self.draw_indicator_colors() |
39 def draw_indicator_colors(self): | |
40 if self.scale_var.get() == 0: | |
41 self['troughcolor'] = 'black' | |
42 else: | |
43 self['troughcolor'] = 'blue' | |
0 | 44 |
45 class SubmasterTk(Frame): | |
46 def __init__(self, master, name, current_level): | |
146 | 47 Frame.__init__(self, master, bd=1, relief='raised', bg='black') |
343
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
48 self.name = name |
0 | 49 self.slider_var = DoubleVar() |
50 self.slider_var.set(current_level) | |
51 self.scale = SubScale(self, variable=self.slider_var, width=20) | |
287
5322639d61e9
refactoring and little fixes in curvecalc and keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
286
diff
changeset
|
52 namelabel = Label(self, text=name, font="Arial 9", bg='black', |
146 | 53 fg='white') |
54 namelabel.pack(side=TOP) | |
205
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
55 levellabel = Label(self, textvariable=self.slider_var, font="Arial 11", |
146 | 56 bg='black', fg='white') |
57 levellabel.pack(side=TOP) | |
0 | 58 self.scale.pack(side=BOTTOM, expand=1, fill=BOTH) |
343
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
59 bindkeys(self, "<Control-Key-l>", self.launch_subcomposer) |
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
60 |
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
61 def launch_subcomposer(self, *args): |
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
62 subprocess.Popen(["bin/subcomposer", self.name]) |
0 | 63 |
253
a92b6d1ac072
SubClient created, keyboardcomposer and gyrocontroller use it now
David McClosky <dmcc@bigasterisk.com>
parents:
246
diff
changeset
|
64 class KeyboardComposer(Frame, SubClient): |
a92b6d1ac072
SubClient created, keyboardcomposer and gyrocontroller use it now
David McClosky <dmcc@bigasterisk.com>
parents:
246
diff
changeset
|
65 def __init__(self, root, submasters, current_sub_levels=None): |
146 | 66 Frame.__init__(self, root, bg='black') |
253
a92b6d1ac072
SubClient created, keyboardcomposer and gyrocontroller use it now
David McClosky <dmcc@bigasterisk.com>
parents:
246
diff
changeset
|
67 SubClient.__init__(self) |
0 | 68 self.submasters = submasters |
270
54774cba50c9
revive kcclient and fix subcomposer so kcclient works through refreshes
Drew Perttula <drewp@bigasterisk.com>
parents:
268
diff
changeset
|
69 self.name_to_subtk = {} |
136 | 70 self.current_sub_levels = {} |
343
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
71 if current_sub_levels is not None: |
136 | 72 self.current_sub_levels = current_sub_levels |
73 else: | |
74 try: | |
75 self.current_sub_levels = \ | |
76 pickle.load(file('.keyboardcomposer.savedlevels')) | |
77 except IOError: | |
78 pass | |
0 | 79 |
136 | 80 self.draw_ui() |
81 self.send_levels_loop() | |
82 def draw_ui(self): | |
0 | 83 self.rows = [] # this holds Tk Frames for each row |
84 self.slider_vars = {} # this holds subname:sub Tk vars | |
85 self.slider_table = {} # this holds coords:sub Tk vars | |
270
54774cba50c9
revive kcclient and fix subcomposer so kcclient works through refreshes
Drew Perttula <drewp@bigasterisk.com>
parents:
268
diff
changeset
|
86 self.name_to_subtk.clear() # subname : SubmasterTk instance |
0 | 87 self.current_row = 0 |
88 | |
89 self.make_key_hints() | |
90 self.draw_sliders() | |
91 self.highlight_row(self.current_row) | |
92 self.rows[self.current_row].focus() | |
136 | 93 |
146 | 94 self.buttonframe = Frame(self, bg='black') |
95 self.buttonframe.pack(side=BOTTOM) | |
275
c7bba03ddc36
keyboardcomposer has 'All to Zero' aka blackout
David McClosky <dmcc@bigasterisk.com>
parents:
270
diff
changeset
|
96 self.alltozerobutton = Button(self.buttonframe, text="All to Zero", |
c7bba03ddc36
keyboardcomposer has 'All to Zero' aka blackout
David McClosky <dmcc@bigasterisk.com>
parents:
270
diff
changeset
|
97 command=self.alltozero, bg='black', fg='white') |
c7bba03ddc36
keyboardcomposer has 'All to Zero' aka blackout
David McClosky <dmcc@bigasterisk.com>
parents:
270
diff
changeset
|
98 self.alltozerobutton.pack(side='left') |
146 | 99 self.refreshbutton = Button(self.buttonframe, text="Refresh", |
100 command=self.refresh, bg='black', fg='white') | |
101 self.refreshbutton.pack(side=LEFT) | |
102 self.save_stage_button = Button(self.buttonframe, text="Save", | |
103 command=lambda: self.save_current_stage(self.sub_name.get()), | |
104 bg='black', fg='white') | |
105 self.save_stage_button.pack(side=LEFT) | |
106 self.sub_name = Entry(self.buttonframe, bg='black', fg='white') | |
107 self.sub_name.pack(side=LEFT) | |
136 | 108 self.stop_frequent_update_time = 0 |
0 | 109 def make_key_hints(self): |
110 keyhintrow = Frame(self) | |
111 | |
112 col = 0 | |
113 for upkey, downkey in zip(nudge_keys['up'], | |
114 nudge_keys['down']): | |
115 # what a hack! | |
116 downkey = downkey.replace('semicolon', ';') | |
136 | 117 upkey, downkey = (upkey.upper(), downkey.upper()) |
0 | 118 |
119 # another what a hack! | |
120 keylabel = Label(keyhintrow, text='%s\n%s' % (upkey, downkey), | |
146 | 121 width=1, font=('Arial', 10), bg='red', fg='white', anchor='c') |
0 | 122 keylabel.pack(side=LEFT, expand=1, fill=X) |
123 col += 1 | |
124 | |
125 keyhintrow.pack(fill=X, expand=0) | |
126 self.keyhints = keyhintrow | |
127 def setup_key_nudgers(self, tkobject): | |
128 for d, keys in nudge_keys.items(): | |
129 for key in keys: | |
130 # lowercase makes full=0 | |
131 keysym = "<KeyPress-%s>" % key | |
132 tkobject.bind(keysym, \ | |
133 lambda evt, num=keys.index(key), d=d: \ | |
134 self.got_nudger(num, d)) | |
135 | |
136 # uppercase makes full=1 | |
137 keysym = "<KeyPress-%s>" % key.upper() | |
138 keysym = keysym.replace('SEMICOLON', 'colon') | |
139 tkobject.bind(keysym, \ | |
140 lambda evt, num=keys.index(key), d=d: \ | |
141 self.got_nudger(num, d, full=1)) | |
142 | |
205
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
143 # Row changing: |
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
144 # Page dn, C-n, and ] do down |
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
145 # Page up, C-p, and ' do up |
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
146 for key in '<Prior> <Next> <Control-n> <Control-p> ' \ |
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
147 '<Key-bracketright> <Key-apostrophe>'.split(): |
0 | 148 tkobject.bind(key, self.change_row) |
149 | |
150 def change_row(self, event): | |
151 diff = 1 | |
205
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
152 if event.keysym in ('Prior', 'p', 'bracketright'): |
0 | 153 diff = -1 |
154 old_row = self.current_row | |
155 self.current_row += diff | |
156 self.current_row = max(0, self.current_row) | |
157 self.current_row = min(len(self.rows) - 1, self.current_row) | |
158 self.unhighlight_row(old_row) | |
159 self.highlight_row(self.current_row) | |
160 row = self.rows[self.current_row] | |
161 self.keyhints.pack_configure(before=row) | |
162 def got_nudger(self, number, direction, full=0): | |
163 subtk = self.slider_table[(self.current_row, number)] | |
164 if direction == 'up': | |
165 if full: | |
136 | 166 subtk.scale.fade(1) |
0 | 167 else: |
168 subtk.scale.increase() | |
169 else: | |
170 if full: | |
171 subtk.scale.fade(0) | |
172 else: | |
173 subtk.scale.decrease() | |
174 def draw_sliders(self): | |
175 self.tk_focusFollowsMouse() | |
176 | |
177 rowcount = -1 | |
178 col = 0 | |
136 | 179 for sub in self.submasters.get_all_subs(): |
0 | 180 if col == 0: # make new row |
181 row = self.make_row() | |
182 rowcount += 1 | |
183 current_level = self.current_sub_levels.get(sub.name, 0) | |
184 subtk = self.draw_sub_slider(row, col, sub.name, current_level) | |
185 self.slider_table[(rowcount, col)] = subtk | |
205
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
186 self.name_to_subtk[sub.name] = subtk |
0 | 187 col += 1 |
188 col %= 10 | |
136 | 189 |
146 | 190 def slider_changed(x, y, z, subtk=subtk): |
191 subtk.scale.draw_indicator_colors() | |
192 self.send_levels() | |
193 | |
194 subtk.slider_var.trace('w', slider_changed) | |
0 | 195 def make_row(self): |
146 | 196 row = Frame(self, bd=2, bg='black') |
0 | 197 row.pack(expand=1, fill=BOTH) |
198 self.setup_key_nudgers(row) | |
199 self.rows.append(row) | |
200 return row | |
201 def draw_sub_slider(self, row, col, name, current_level): | |
202 subtk = SubmasterTk(row, name, current_level) | |
203 subtk.place(relx=col * 0.1, rely=0, relwidth=0.1, relheight=1) | |
204 self.setup_key_nudgers(subtk.scale) | |
205 | |
206 self.slider_vars[name] = subtk.slider_var | |
207 return subtk | |
208 def highlight_row(self, row): | |
209 row = self.rows[row] | |
210 row['bg'] = 'red' | |
211 def unhighlight_row(self, row): | |
212 row = self.rows[row] | |
146 | 213 row['bg'] = 'black' |
0 | 214 def get_levels(self): |
215 return dict([(name, slidervar.get()) | |
216 for name, slidervar in self.slider_vars.items()]) | |
146 | 217 def get_levels_as_sub(self): |
136 | 218 scaledsubs = [self.submasters.get_sub_by_name(sub) * level \ |
286
2848cf5e14c5
keyboardcomposer: skip subs at 0 when combining, temporary subs don't listen for reloads
David McClosky <dmcc@bigasterisk.com>
parents:
278
diff
changeset
|
219 for sub, level in self.get_levels().items() if level > 0.0] |
136 | 220 |
221 maxes = sub_maxes(*scaledsubs) | |
146 | 222 return maxes |
223 def save_current_stage(self, subname): | |
224 print "saving current levels as", subname | |
225 sub = self.get_levels_as_sub() | |
226 sub.name = subname | |
205
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
227 sub.temporary = 0 |
146 | 228 sub.save() |
229 | |
136 | 230 def save(self): |
231 pickle.dump(self.get_levels(), | |
232 file('.keyboardcomposer.savedlevels', 'w')) | |
233 def send_frequent_updates(self): | |
234 """called when we get a fade -- send events as quickly as possible""" | |
235 if time.time() <= self.stop_frequent_update_time: | |
236 self.send_levels() | |
237 self.after(10, self.send_frequent_updates) | |
146 | 238 |
136 | 239 def refresh(self): |
240 self.save() | |
241 self.submasters = Submasters() | |
242 self.current_sub_levels = \ | |
243 pickle.load(file('.keyboardcomposer.savedlevels')) | |
244 for r in self.rows: | |
245 r.destroy() | |
246 self.keyhints.destroy() | |
146 | 247 self.buttonframe.destroy() |
136 | 248 self.draw_ui() |
0 | 249 |
275
c7bba03ddc36
keyboardcomposer has 'All to Zero' aka blackout
David McClosky <dmcc@bigasterisk.com>
parents:
270
diff
changeset
|
250 def alltozero(self): |
c7bba03ddc36
keyboardcomposer has 'All to Zero' aka blackout
David McClosky <dmcc@bigasterisk.com>
parents:
270
diff
changeset
|
251 for name, subtk in self.name_to_subtk.items(): |
c7bba03ddc36
keyboardcomposer has 'All to Zero' aka blackout
David McClosky <dmcc@bigasterisk.com>
parents:
270
diff
changeset
|
252 if subtk.scale.scale_var.get() != 0: |
c7bba03ddc36
keyboardcomposer has 'All to Zero' aka blackout
David McClosky <dmcc@bigasterisk.com>
parents:
270
diff
changeset
|
253 subtk.scale.fade(value=0.0, length=0) |
c7bba03ddc36
keyboardcomposer has 'All to Zero' aka blackout
David McClosky <dmcc@bigasterisk.com>
parents:
270
diff
changeset
|
254 |
205
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
255 class LevelServer(xmlrpc.XMLRPC): |
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
256 def __init__(self,name_to_subtk): |
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
257 self.name_to_subtk = name_to_subtk |
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
258 |
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
259 def xmlrpc_fadesub(self,subname,level,secs): |
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
260 """submaster will fade to level in secs""" |
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
261 try: |
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
262 self.name_to_subtk[subname].scale.fade(level,secs) |
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
263 ret='ok' |
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
264 except Exception,e: |
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
265 ret=str(e) |
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
266 return ret |
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
267 |
0 | 268 if __name__ == "__main__": |
343
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
269 parser = OptionParser() |
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
270 parser.add_option('--nonpersistent', action="store_true", |
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
271 help="don't load or save levels") |
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
272 opts, args = parser.parse_args() |
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
273 |
136 | 274 s = Submasters() |
0 | 275 |
276 root = Tk() | |
136 | 277 tl = toplevelat("Keyboard Composer", existingtoplevel=root) |
264
0f112a7dd6b3
fix window positoins for subcomposer and curvecalc. now saves geometry continuously
drewp@bigasterisk.com
parents:
260
diff
changeset
|
278 |
343
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
279 startLevels = None |
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
280 if opts.nonpersistent: |
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
281 startLevels = {} |
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
282 kc = KeyboardComposer(tl, s, startLevels) |
0 | 283 kc.pack(fill=BOTH, expand=1) |
205
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
284 |
343
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
285 for helpline in ["Bindings: B3 mute; C-l edit levels in subcomposer"]: |
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
286 tk.Label(root,text=helpline, font="Helvetica -12 italic", |
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
287 anchor='w').pack(side='top',fill='x') |
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
288 |
278
d20fda03a041
LevelServer in keyboardcomposer fails less gracelessly
David McClosky <dmcc@bigasterisk.com>
parents:
275
diff
changeset
|
289 import twisted.internet |
d20fda03a041
LevelServer in keyboardcomposer fails less gracelessly
David McClosky <dmcc@bigasterisk.com>
parents:
275
diff
changeset
|
290 try: |
d20fda03a041
LevelServer in keyboardcomposer fails less gracelessly
David McClosky <dmcc@bigasterisk.com>
parents:
275
diff
changeset
|
291 ls = LevelServer(kc.name_to_subtk) |
d20fda03a041
LevelServer in keyboardcomposer fails less gracelessly
David McClosky <dmcc@bigasterisk.com>
parents:
275
diff
changeset
|
292 reactor.listenTCP(networking.kcPort(), server.Site(ls)) |
d20fda03a041
LevelServer in keyboardcomposer fails less gracelessly
David McClosky <dmcc@bigasterisk.com>
parents:
275
diff
changeset
|
293 except twisted.internet.error.CannotListenError, e: |
d20fda03a041
LevelServer in keyboardcomposer fails less gracelessly
David McClosky <dmcc@bigasterisk.com>
parents:
275
diff
changeset
|
294 print "Can't (and won't!) start level server:" |
d20fda03a041
LevelServer in keyboardcomposer fails less gracelessly
David McClosky <dmcc@bigasterisk.com>
parents:
275
diff
changeset
|
295 print e |
205
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
296 |
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
297 root.protocol('WM_DELETE_WINDOW', reactor.stop) |
343
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
298 if not opts.nonpersistent: |
fe9dff7dbffd
added C-l to launch subcomposer- in progress
Drew Perttula <drewp@bigasterisk.com>
parents:
287
diff
changeset
|
299 reactor.addSystemEventTrigger('after', 'shutdown', kc.save) |
264
0f112a7dd6b3
fix window positoins for subcomposer and curvecalc. now saves geometry continuously
drewp@bigasterisk.com
parents:
260
diff
changeset
|
300 |
205
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
167
diff
changeset
|
301 tksupport.install(root,ms=10) |
287
5322639d61e9
refactoring and little fixes in curvecalc and keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
286
diff
changeset
|
302 if 0: |
5322639d61e9
refactoring and little fixes in curvecalc and keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
286
diff
changeset
|
303 sys.path.append("/home/drewp/projects/cuisine/pour") |
5322639d61e9
refactoring and little fixes in curvecalc and keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
286
diff
changeset
|
304 from utils import runstats |
5322639d61e9
refactoring and little fixes in curvecalc and keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
286
diff
changeset
|
305 runstats("reactor.run()") |
5322639d61e9
refactoring and little fixes in curvecalc and keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
286
diff
changeset
|
306 else: |
5322639d61e9
refactoring and little fixes in curvecalc and keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
286
diff
changeset
|
307 reactor.run() |