Mercurial > code > home > repos > light9
annotate bin/bumppad @ 1859:f066d6e874db
2to3 with these fixers: all idioms set_literal
Ignore-this: cbd28518218c2f0ddce8c4f92d3b8b33
author | drewp@bigasterisk.com |
---|---|
date | Wed, 22 May 2019 00:08:22 +0000 |
parents | 7772cc48e016 |
children | 5bcb950024af |
rev | line source |
---|---|
1012 | 1 #!bin/python |
1859
f066d6e874db
2to3 with these fixers: all idioms set_literal
drewp@bigasterisk.com
parents:
1858
diff
changeset
|
2 |
204 | 3 import sys, time, math |
1859
f066d6e874db
2to3 with these fixers: all idioms set_literal
drewp@bigasterisk.com
parents:
1858
diff
changeset
|
4 import tkinter as tk |
204 | 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 |
1858 | 10 from light9.Submaster import Submaster, sub_maxes |
11 | |
204 | 12 |
13 class pad(tk.Frame): | |
1858 | 14 levs = None # Submaster : level |
15 | |
16 def __init__(self, master, root, mag): | |
17 make_attributes_from_args('master', 'mag') | |
18 tk.Frame.__init__(self, master) | |
19 self.levs = {} | |
20 for xy, key, subname in [ | |
21 ((1, 1), 'KP_Up', 'centered'), | |
22 ((1, 3), "KP_Down", 'third-c'), | |
23 ((0, 2), 'KP_Left', 'scoop-l'), | |
24 ((2, 2), 'KP_Right', 'scoop-r'), | |
25 ((1, 0), 'KP_Divide', 'cyc'), | |
26 ((0, 3), "KP_End", 'hottest'), | |
27 ((2, 3), 'KP_Next', 'deepblues'), | |
28 ((0, 4), 'KP_Insert', "zip_red"), | |
29 ((2, 4), 'KP_Delete', "zip_orange"), | |
30 ((3, 1), 'KP_Add', 'strobedim'), | |
31 ((3, 3), 'KP_Enter', 'zip_blue'), | |
32 ((1, 2), 'KP_Begin', 'scoop-c'), | |
33 ]: | |
34 | |
204 | 35 sub = Submaster(subname) |
1858 | 36 self.levs[sub] = 0 |
37 | |
38 l = tk.Label(self, | |
39 font="arial 12 bold", | |
40 anchor='w', | |
41 height=2, | |
42 relief='groove', | |
43 bd=5, | |
44 text="%s\n%s" % (key.replace('KP_', ''), sub.name)) | |
45 l.grid(column=xy[0], row=xy[1], sticky='news') | |
46 | |
47 root.bind( | |
48 "<KeyPress-%s>" % key, lambda ev, sub=sub: self.bumpto(sub, 1)) | |
49 root.bind("<KeyRelease-%s>" % key, | |
50 lambda ev, sub=sub: self.bumpto(sub, 0)) | |
51 | |
52 def bumpto(self, sub, lev): | |
53 now = time.time() | |
54 self.levs[sub] = lev * self.mag.get() | |
204 | 55 self.master.after_idle(self.output) |
1858 | 56 |
204 | 57 def output(self): |
1859
f066d6e874db
2to3 with these fixers: all idioms set_literal
drewp@bigasterisk.com
parents:
1858
diff
changeset
|
58 dmx = sub_maxes(*[s * l for s, l in list(self.levs.items())]).get_dmx_list() |
1858 | 59 dmxclient.outputlevels(dmx, clientid="bumppad") |
60 | |
61 | |
62 root = tk.Tk() | |
204 | 63 root.tk_setPalette("maroon4") |
234
079cc244a59e
port bumppad to new package system, small gui fixes
drewp@bigasterisk.com
parents:
204
diff
changeset
|
64 root.wm_title("bumppad") |
079cc244a59e
port bumppad to new package system, small gui fixes
drewp@bigasterisk.com
parents:
204
diff
changeset
|
65 mag = tk.DoubleVar() |
204 | 66 |
1858 | 67 tk.Label(root, |
68 text="Keypad press/release activate sub; 1..5 set mag", | |
69 font="Helvetica -12 italic", | |
70 anchor='w').pack(side='bottom', fill='x') | |
71 | |
72 pad(root, root, mag).pack(side='left', fill='both', exp=1) | |
204 | 73 |
1858 | 74 magscl = tk.Scale(root, |
75 orient='vertical', | |
76 from_=1, | |
77 to=0, | |
78 res=.01, | |
79 showval=1, | |
80 variable=mag, | |
81 label='mag', | |
82 relief='raised', | |
83 bd=1) | |
84 for i in range(1, 6): | |
85 root.bind("<Key-%s>" % i, lambda ev, i=i: mag.set(math.sqrt((i) / 5))) | |
86 magscl.pack(side='left', fill='y') | |
234
079cc244a59e
port bumppad to new package system, small gui fixes
drewp@bigasterisk.com
parents:
204
diff
changeset
|
87 |
204 | 88 root.mainloop() |