comparison 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
comparison
equal deleted inserted replaced
342:2c782ca93e73 343:fe9dff7dbffd
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 from __future__ import division, nested_scopes 3 from __future__ import division, nested_scopes
4 import sys, time 4 import os, sys, time, subprocess
5 from optparse import OptionParser
5 6
6 from twisted.internet import reactor, tksupport 7 from twisted.internet import reactor, tksupport
7 from twisted.web import xmlrpc, server 8 from twisted.web import xmlrpc, server
8 from Tix import * 9 from Tix import *
10 import Tix as tk
9 import pickle 11 import pickle
10 12
11 import run_local 13 import run_local
12 from light9.Fadable import Fadable 14 from light9.Fadable import Fadable
13 from light9.Submaster import Submasters, sub_maxes 15 from light9.Submaster import Submasters, sub_maxes
14 from light9.subclient import SubClient 16 from light9.subclient import SubClient
15 from light9 import dmxclient, showconfig, networking 17 from light9 import dmxclient, showconfig, networking
16 from light9.uihelpers import toplevelat 18 from light9.uihelpers import toplevelat, bindkeys
17 19
18 nudge_keys = { 20 nudge_keys = {
19 'up' : list('qwertyuiop'), 21 'up' : list('qwertyuiop'),
20 'down' : list('asdfghjkl') 22 'down' : list('asdfghjkl')
21 } 23 }
41 self['troughcolor'] = 'blue' 43 self['troughcolor'] = 'blue'
42 44
43 class SubmasterTk(Frame): 45 class SubmasterTk(Frame):
44 def __init__(self, master, name, current_level): 46 def __init__(self, master, name, current_level):
45 Frame.__init__(self, master, bd=1, relief='raised', bg='black') 47 Frame.__init__(self, master, bd=1, relief='raised', bg='black')
48 self.name = name
46 self.slider_var = DoubleVar() 49 self.slider_var = DoubleVar()
47 self.slider_var.set(current_level) 50 self.slider_var.set(current_level)
48 self.scale = SubScale(self, variable=self.slider_var, width=20) 51 self.scale = SubScale(self, variable=self.slider_var, width=20)
49 namelabel = Label(self, text=name, font="Arial 9", bg='black', 52 namelabel = Label(self, text=name, font="Arial 9", bg='black',
50 fg='white') 53 fg='white')
51 namelabel.pack(side=TOP) 54 namelabel.pack(side=TOP)
52 levellabel = Label(self, textvariable=self.slider_var, font="Arial 11", 55 levellabel = Label(self, textvariable=self.slider_var, font="Arial 11",
53 bg='black', fg='white') 56 bg='black', fg='white')
54 levellabel.pack(side=TOP) 57 levellabel.pack(side=TOP)
55 self.scale.pack(side=BOTTOM, expand=1, fill=BOTH) 58 self.scale.pack(side=BOTTOM, expand=1, fill=BOTH)
59 bindkeys(self, "<Control-Key-l>", self.launch_subcomposer)
60
61 def launch_subcomposer(self, *args):
62 subprocess.Popen(["bin/subcomposer", self.name])
56 63
57 class KeyboardComposer(Frame, SubClient): 64 class KeyboardComposer(Frame, SubClient):
58 def __init__(self, root, submasters, current_sub_levels=None): 65 def __init__(self, root, submasters, current_sub_levels=None):
59 Frame.__init__(self, root, bg='black') 66 Frame.__init__(self, root, bg='black')
60 SubClient.__init__(self) 67 SubClient.__init__(self)
61 self.submasters = submasters 68 self.submasters = submasters
62 self.name_to_subtk = {} 69 self.name_to_subtk = {}
63 self.current_sub_levels = {} 70 self.current_sub_levels = {}
64 if current_sub_levels: 71 if current_sub_levels is not None:
65 self.current_sub_levels = current_sub_levels 72 self.current_sub_levels = current_sub_levels
66 else: 73 else:
67 try: 74 try:
68 self.current_sub_levels = \ 75 self.current_sub_levels = \
69 pickle.load(file('.keyboardcomposer.savedlevels')) 76 pickle.load(file('.keyboardcomposer.savedlevels'))
257 except Exception,e: 264 except Exception,e:
258 ret=str(e) 265 ret=str(e)
259 return ret 266 return ret
260 267
261 if __name__ == "__main__": 268 if __name__ == "__main__":
269 parser = OptionParser()
270 parser.add_option('--nonpersistent', action="store_true",
271 help="don't load or save levels")
272 opts, args = parser.parse_args()
273
262 s = Submasters() 274 s = Submasters()
263 275
264 root = Tk() 276 root = Tk()
265 tl = toplevelat("Keyboard Composer", existingtoplevel=root) 277 tl = toplevelat("Keyboard Composer", existingtoplevel=root)
266 278
267 kc = KeyboardComposer(tl, s) 279 startLevels = None
280 if opts.nonpersistent:
281 startLevels = {}
282 kc = KeyboardComposer(tl, s, startLevels)
268 kc.pack(fill=BOTH, expand=1) 283 kc.pack(fill=BOTH, expand=1)
284
285 for helpline in ["Bindings: B3 mute; C-l edit levels in subcomposer"]:
286 tk.Label(root,text=helpline, font="Helvetica -12 italic",
287 anchor='w').pack(side='top',fill='x')
269 288
270 import twisted.internet 289 import twisted.internet
271 try: 290 try:
272 ls = LevelServer(kc.name_to_subtk) 291 ls = LevelServer(kc.name_to_subtk)
273 reactor.listenTCP(networking.kcPort(), server.Site(ls)) 292 reactor.listenTCP(networking.kcPort(), server.Site(ls))
274 except twisted.internet.error.CannotListenError, e: 293 except twisted.internet.error.CannotListenError, e:
275 print "Can't (and won't!) start level server:" 294 print "Can't (and won't!) start level server:"
276 print e 295 print e
277 296
278 root.protocol('WM_DELETE_WINDOW', reactor.stop) 297 root.protocol('WM_DELETE_WINDOW', reactor.stop)
279 reactor.addSystemEventTrigger('after', 'shutdown', kc.save) 298 if not opts.nonpersistent:
299 reactor.addSystemEventTrigger('after', 'shutdown', kc.save)
280 300
281 tksupport.install(root,ms=10) 301 tksupport.install(root,ms=10)
282 if 0: 302 if 0:
283 sys.path.append("/home/drewp/projects/cuisine/pour") 303 sys.path.append("/home/drewp/projects/cuisine/pour")
284 from utils import runstats 304 from utils import runstats