Mercurial > code > home > repos > light9
annotate bin/bumppad @ 258:c9940e4e68d6
TkGyro: read subs from argv or stdin, cleanups
Some documentation and code reorganization/cleanups
author | David McClosky <dmcc@bigasterisk.com> |
---|---|
date | Thu, 16 Jun 2005 05:16:30 +0000 |
parents | 079cc244a59e |
children | 34db49e1bc20 |
rev | line source |
---|---|
204 | 1 #!/usr/bin/env python |
2 from __future__ import division,nested_scopes | |
3 import sys, time, math | |
4 import Tkinter as tk | |
5 | |
234
079cc244a59e
port bumppad to new package system, small gui fixes
drewp@bigasterisk.com
parents:
204
diff
changeset
|
6 import run_local |
079cc244a59e
port bumppad to new package system, small gui fixes
drewp@bigasterisk.com
parents:
204
diff
changeset
|
7 import light9.dmxclient as dmxclient |
079cc244a59e
port bumppad to new package system, small gui fixes
drewp@bigasterisk.com
parents:
204
diff
changeset
|
8 from light9.TLUtility import make_attributes_from_args |
204 | 9 |
234
079cc244a59e
port bumppad to new package system, small gui fixes
drewp@bigasterisk.com
parents:
204
diff
changeset
|
10 from light9.Submaster import Submaster,sub_maxes |
204 | 11 |
12 class pad(tk.Frame): | |
13 levs = None # Submaster : level | |
14 def __init__(self,master,root,mag): | |
15 make_attributes_from_args('master','mag') | |
16 tk.Frame.__init__(self,master) | |
17 self.levs={} | |
18 for xy,key,subname in [ | |
19 ((1,1),'KP_Up','upstage'), | |
20 ((1,3),"KP_Down",'narrow-c'), | |
21 ((0,2),'KP_Left','left1'), | |
22 ((2,2),'KP_Right','right1'), | |
23 ((1,0),'KP_Divide','cyc'), | |
24 ((0,3),"KP_End",'edge-l'), | |
25 ((2,3),'KP_Next','edge-r'), | |
26 ((0,4),'KP_Insert',"zip_red"), | |
27 ((2,4),'KP_Delete',"zip_orange"), | |
28 ((3,1),'KP_Add','zip_green'), | |
29 ((3,3),'KP_Enter','zip_blue'), | |
30 ((1,2),'KP_Begin','downfront'), | |
31 ]: | |
32 | |
33 sub = Submaster(subname) | |
34 self.levs[sub]=0 | |
35 | |
36 l = tk.Label(self,font="arial 12 bold",anchor='w',height=2, | |
37 relief='groove',bd=5, | |
38 text="%s\n%s" % (key.replace('KP_',''),sub.name)) | |
39 l.grid(column=xy[0],row=xy[1],sticky='news') | |
40 | |
41 root.bind("<KeyPress-%s>"%key, | |
42 lambda ev,sub=sub: self.bumpto(sub,1)) | |
43 root.bind("<KeyRelease-%s>"%key, | |
44 lambda ev,sub=sub: self.bumpto(sub,0)) | |
45 def bumpto(self,sub,lev): | |
46 now=time.time() | |
47 self.levs[sub]=lev*self.mag.get() | |
48 self.master.after_idle(self.output) | |
49 def output(self): | |
50 dmx = sub_maxes(*[s*l for s,l in self.levs.items()]).get_dmx_list() | |
51 dmxclient.outputlevels(dmx,clientid="bumppad") | |
52 | |
53 root=tk.Tk() | |
54 root.tk_setPalette("maroon4") | |
234
079cc244a59e
port bumppad to new package system, small gui fixes
drewp@bigasterisk.com
parents:
204
diff
changeset
|
55 root.wm_title("bumppad") |
079cc244a59e
port bumppad to new package system, small gui fixes
drewp@bigasterisk.com
parents:
204
diff
changeset
|
56 mag = tk.DoubleVar() |
204 | 57 |
234
079cc244a59e
port bumppad to new package system, small gui fixes
drewp@bigasterisk.com
parents:
204
diff
changeset
|
58 tk.Label(root,text="Keypad press/release activate sub; 1..5 set mag", |
079cc244a59e
port bumppad to new package system, small gui fixes
drewp@bigasterisk.com
parents:
204
diff
changeset
|
59 font="Helvetica -12 italic",anchor='w').pack(side='bottom',fill='x') |
204 | 60 |
61 pad(root,root,mag).pack(side='left',fill='both',exp=1) | |
62 | |
63 magscl = tk.Scale(root,orient='vertical',from_=1,to=0,res=.01, | |
64 showval=1,variable=mag,label='mag',relief='raised',bd=1) | |
65 for i in range(1,6): | |
66 root.bind("<Key-%s>"%i,lambda ev,i=i: mag.set(math.sqrt((i )/5))) | |
67 magscl.pack(side='left',fill='y') | |
234
079cc244a59e
port bumppad to new package system, small gui fixes
drewp@bigasterisk.com
parents:
204
diff
changeset
|
68 |
079cc244a59e
port bumppad to new package system, small gui fixes
drewp@bigasterisk.com
parents:
204
diff
changeset
|
69 |
204 | 70 root.mainloop() |