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