Mercurial > code > home > repos > light9
annotate bin/bumppad @ 2293:c070f46c0761
you can ask to apply empty patch and it will no-op
author | drewp@bigasterisk.com |
---|---|
date | Tue, 30 May 2023 00:59:20 -0700 |
parents | 5bcb950024af |
children |
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): |
1860 | 58 dmx = sub_maxes(*[s * l |
59 for s, l in list(self.levs.items())]).get_dmx_list() | |
1858 | 60 dmxclient.outputlevels(dmx, clientid="bumppad") |
61 | |
62 | |
63 root = tk.Tk() | |
204 | 64 root.tk_setPalette("maroon4") |
234
079cc244a59e
port bumppad to new package system, small gui fixes
drewp@bigasterisk.com
parents:
204
diff
changeset
|
65 root.wm_title("bumppad") |
079cc244a59e
port bumppad to new package system, small gui fixes
drewp@bigasterisk.com
parents:
204
diff
changeset
|
66 mag = tk.DoubleVar() |
204 | 67 |
1858 | 68 tk.Label(root, |
69 text="Keypad press/release activate sub; 1..5 set mag", | |
70 font="Helvetica -12 italic", | |
71 anchor='w').pack(side='bottom', fill='x') | |
72 | |
73 pad(root, root, mag).pack(side='left', fill='both', exp=1) | |
204 | 74 |
1858 | 75 magscl = tk.Scale(root, |
76 orient='vertical', | |
77 from_=1, | |
78 to=0, | |
79 res=.01, | |
80 showval=1, | |
81 variable=mag, | |
82 label='mag', | |
83 relief='raised', | |
84 bd=1) | |
85 for i in range(1, 6): | |
86 root.bind("<Key-%s>" % i, lambda ev, i=i: mag.set(math.sqrt((i) / 5))) | |
87 magscl.pack(side='left', fill='y') | |
234
079cc244a59e
port bumppad to new package system, small gui fixes
drewp@bigasterisk.com
parents:
204
diff
changeset
|
88 |
204 | 89 root.mainloop() |