Mercurial > code > home > repos > light9
annotate bin/subcomposer @ 833:bdfdfea84510
colored logs
Ignore-this: 74b7fb320ebca032b2976da3d00e05ca
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Tue, 04 Jun 2013 23:51:57 +0000 |
parents | 0f7e99d02dc6 |
children | ae359590eb8a |
rev | line source |
---|---|
729
b5efddd80dad
update more shbang lines
Drew Perttula <drewp@bigasterisk.com>
parents:
577
diff
changeset
|
1 #!bin/python |
0 | 2 |
3 from __future__ import division, nested_scopes | |
342
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
4 from optparse import OptionParser |
831
0f7e99d02dc6
subcomposer support logging. don't start with a bogus sub
Drew Perttula <drewp@bigasterisk.com>
parents:
818
diff
changeset
|
5 import logging |
0 | 6 import Tkinter as tk |
802 | 7 import louie as dispatcher |
803 | 8 from twisted.internet import reactor, tksupport, task |
817
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
9 from rdflib import URIRef |
0 | 10 |
833 | 11 from run_local import log |
209
1a84c5e83d3e
dmxserver and subcomposer work in new layout
drewp@bigasterisk.com
parents:
201
diff
changeset
|
12 from light9.dmxchanedit import Levelbox |
803 | 13 from light9 import dmxclient, Patch, Submaster, showconfig, prof |
455
9dd2baa41cca
subcomposer remembers window position
drewp@bigasterisk.com
parents:
450
diff
changeset
|
14 from light9.uihelpers import toplevelat |
803 | 15 from light9.rdfdb.syncedgraph import SyncedGraph |
810 | 16 from light9.rdfdb import clientsession |
817
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
17 from light9.tkdnd import initTkdnd, dragSourceRegister, dropTargetRegister |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
18 |
833 | 19 log.setLevel(logging.DEBUG) |
831
0f7e99d02dc6
subcomposer support logging. don't start with a bogus sub
Drew Perttula <drewp@bigasterisk.com>
parents:
818
diff
changeset
|
20 |
818
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
21 class _NoNewVal(object): |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
22 pass |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
23 |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
24 class Observable(object): |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
25 """ |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
26 like knockout's observable. Hopefully this can be replaced by a |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
27 better python one |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
28 """ |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
29 def __init__(self, val): |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
30 self.val = val |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
31 self.subscribers = set() |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
32 |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
33 def __call__(self, newVal=_NoNewVal): |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
34 if newVal is _NoNewVal: |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
35 return self.val |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
36 self.val = newVal |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
37 for s in self.subscribers: |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
38 s(newVal) |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
39 |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
40 def subscribe(self, cb, callNow=True): |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
41 """cb is called with new values, and also right now with the |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
42 current value unless you opt out""" |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
43 self.subscribers.add(cb) |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
44 if callNow: |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
45 cb(self.val) |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
46 |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
47 class Local(object): |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
48 """placeholder for the local uri that EditChoice does not |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
49 manage. Set resourceObservable to Local to indicate that you're |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
50 unlinked""" |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
51 |
817
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
52 class EditChoice(tk.Frame): |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
53 """ |
818
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
54 Observable <-> linker UI |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
55 |
817
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
56 widget for tying some UI to a shared resource for editing, or |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
57 unlinking it (which means associating it with a local resource |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
58 that's not named or shared). This object does not own the choice |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
59 of resource; the caller does. |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
60 """ |
818
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
61 def __init__(self, parent, graph, resourceObservable): |
817
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
62 """ |
818
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
63 getResource is called to get the URI of the currently |
817
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
64 """ |
818
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
65 self.frame = tk.Frame(parent, relief='raised',border=8) |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
66 self.frame.pack(side='top') |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
67 tk.Label(self.frame, text="Editing:").pack(side='left') |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
68 self.currentSubFrame = tk.Frame(self.frame) |
817
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
69 self.currentSubFrame.pack(side='left') |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
70 |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
71 self.subIcon = tk.Label(self.currentSubFrame, text="sub1", |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
72 borderwidth=2, |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
73 relief='raised', padx=10, pady=10) |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
74 self.subIcon.pack() |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
75 |
818
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
76 self.resourceObservable = resourceObservable |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
77 resourceObservable.subscribe(self.uriChanged) |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
78 |
817
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
79 dragSourceRegister(self.subIcon, 'copy', 'text/uri-list', |
818
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
80 self.resourceObservable) |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
81 def onEv(ev): |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
82 self.resourceObservable(ev.data) |
817
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
83 return "link" |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
84 self.onEv = onEv |
818
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
85 |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
86 # it would be nice if I didn't receive my own drags here |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
87 dropTargetRegister(self.subIcon, typeList=["*"], onDrop=onEv, |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
88 hoverStyle=dict(background="#555500", bd=3, |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
89 relief='groove')) |
817
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
90 |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
91 tk.Label(self.currentSubFrame, text="local data (drag sub here)").pack() |
818
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
92 b=tk.Button(text="unlink", command=self.switchToLocalSub) |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
93 b.pack() |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
94 |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
95 |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
96 def uriChanged(self, newUri): |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
97 print "chg", newUri |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
98 # i guess i show the label and icon for this |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
99 if newUri is Local: |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
100 self.subIcon.config(text="(local)") |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
101 else: |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
102 self.subIcon.config(text=newUri) |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
103 |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
104 def switchToLocalSub(self): |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
105 self.resourceObservable(Local) |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
106 |
0 | 107 |
108 class Subcomposer(tk.Frame): | |
817
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
109 """ |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
110 <session> l9:currentSub ?sub is the URI of the sub we're tied to for displaying and |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
111 editing. If we don't have a currentSub, then we're actually |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
112 editing a session-local sub called <session> l9:currentSub <sessionLocalSub> |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
113 |
818
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
114 Contains an EditChoice widget |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
115 |
817
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
116 UI actions: |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
117 - drag a sub uri on here to make it the one we're editing |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
118 |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
119 - button to clear the currentSub (putting it back to |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
120 sessionLocalSub, and also resetting sessionLocalSub to be empty |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
121 again) |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
122 |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
123 - drag the sub uri off of here to send it to another receiver, but |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
124 session local sub is not easily addressable elsewhere |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
125 |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
126 - make a new sub: transfers the current data (from a shared sub or |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
127 from the local one) to the new sub. If you're on a local sub, |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
128 the new sub is named automatically, ideally something brief, |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
129 pretty distinct, readable, and based on the lights that are |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
130 on. If you're on a named sub, the new one starts with a |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
131 'namedsub 2' style name. The uri can also be with a '2' suffix, |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
132 although maybe that will be stupid. If you change the name |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
133 before anyone knows about this uri, we could update the current |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
134 sub's uri to a slug of the new label. |
818
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
135 |
817
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
136 - rename this sub: not available if you're on a local sub. Sets |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
137 the label of a named sub. Might update the uri of the named sub |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
138 if it's new enough that no one else would have that uri. Not |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
139 sure where we measure that 'new enough' value. Maybe track if |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
140 the sub has 'never been dragged out of this subcomposer |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
141 session'? But subs will also show up in other viewers and |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
142 finders. |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
143 |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
144 """ |
810 | 145 def __init__(self, master, graph, session): |
0 | 146 tk.Frame.__init__(self, master, bg='black') |
803 | 147 self.graph = graph |
810 | 148 self.session = session |
817
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
149 self.currentSub = Submaster.PersistentSubmaster(graph, URIRef('http://hello')) |
0 | 150 |
803 | 151 self.levelbox = Levelbox(self, graph) |
0 | 152 self.levelbox.pack(side='top') |
153 | |
831
0f7e99d02dc6
subcomposer support logging. don't start with a bogus sub
Drew Perttula <drewp@bigasterisk.com>
parents:
818
diff
changeset
|
154 currentUri = Observable(Local) |
818
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
155 |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
156 def pc(val): |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
157 print "change viewed sub to", val |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
158 currentUri.subscribe(pc) |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
159 |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
160 EditChoice(self, self.graph, currentUri).frame.pack(side='top') |
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
161 |
0 | 162 def alltozero(): |
803 | 163 for lev in self.levelbox.levels: |
164 lev.setlevel(0) | |
0 | 165 |
149 | 166 tk.Button(self, text="all to zero", command=alltozero).pack(side='top') |
0 | 167 |
803 | 168 dispatcher.connect(self.sendupdate, "levelchanged") |
0 | 169 |
817
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
170 def switchToLocalSub(self, *args): |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
171 """ |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
172 stop editing a shared sub and go back to our local sub |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
173 """ |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
174 |
342
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
175 def fill_both_boxes(self, subname): |
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
176 for box in [self.savebox, self.loadbox]: |
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
177 box.set(subname) |
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
178 |
351
a6662d61ebcd
SC, KC, CC now run and seem to load and save ok. CC does not have any rdf for its data files
Drew Perttula <drewp@bigasterisk.com>
parents:
342
diff
changeset
|
179 def savenewsub(self, subname): |
0 | 180 leveldict={} |
181 for i,lev in zip(range(len(self.levels)),self.levels): | |
182 if lev!=0: | |
183 leveldict[Patch.get_channel_name(i+1)]=lev | |
342
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
184 |
351
a6662d61ebcd
SC, KC, CC now run and seem to load and save ok. CC does not have any rdf for its data files
Drew Perttula <drewp@bigasterisk.com>
parents:
342
diff
changeset
|
185 s=Submaster.Submaster(subname,leveldict=leveldict) |
0 | 186 s.save() |
802 | 187 |
810 | 188 # this is going to be more like 'tie to sub' and 'untied' |
342
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
189 def loadsub(self, subname): |
0 | 190 """puts a sub into the levels, replacing old level values""" |
577 | 191 s=Submaster.Submasters(showconfig.getGraph()).get_sub_by_name(subname) |
380
a13f2caf6f25
fix SC dragging after you load a sub
Drew Perttula <drewp@bigasterisk.com>
parents:
351
diff
changeset
|
192 self.set_levels(s.get_dmx_list()) |
0 | 193 dispatcher.send("levelchanged") |
802 | 194 |
803 | 195 def toDmxLevels(self): |
196 # the dmx levels we edit and output, range is 0..1 (dmx chan 1 is | |
197 # the 0 element) | |
198 out = {} | |
199 for lev in self.levelbox.levels: | |
200 out[lev.channelnum] = lev.currentlevel | |
201 if not out: | |
202 return [] | |
818
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
203 |
803 | 204 return [out.get(i, 0) for i in range(max(out.keys()) + 1)] |
818
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
205 |
0 | 206 def sendupdate(self): |
803 | 207 dmxclient.outputlevels(self.toDmxLevels(), twisted=True) |
802 | 208 |
0 | 209 |
342
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
210 class EntryCommand(tk.Frame): |
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
211 def __init__(self, master, verb="Save", cmd=None): |
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
212 tk.Frame.__init__(self, master, bd=2, relief='raised') |
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
213 tk.Label(self, text="Sub name:").pack(side='left') |
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
214 self.cmd = cmd |
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
215 self.entry = tk.Entry(self) |
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
216 self.entry.pack(side='left', expand=True, fill='x') |
818
bf728997bfde
start the observable between editchoice and the editor
drewp@bigasterisk.com
parents:
817
diff
changeset
|
217 |
342
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
218 self.entry.bind("<Return>", self.action) |
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
219 tk.Button(self, text=verb, command=self.action).pack(side='left') |
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
220 |
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
221 def action(self, *args): |
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
222 subname = self.entry.get() |
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
223 self.cmd(subname) |
351
a6662d61ebcd
SC, KC, CC now run and seem to load and save ok. CC does not have any rdf for its data files
Drew Perttula <drewp@bigasterisk.com>
parents:
342
diff
changeset
|
224 print "sub", self.cmd, subname |
342
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
225 |
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
226 def set(self, text): |
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
227 self.entry.delete(0, 'end') |
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
228 self.entry.insert(0, text) |
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
229 |
149 | 230 |
0 | 231 ############################# |
232 | |
233 if __name__ == "__main__": | |
342
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
234 parser = OptionParser(usage="%prog [subname]") |
458
8b307310cc1b
when KC launches SC to edit a sub, don't place the window right on the main SC window
drewp@bigasterisk.com
parents:
455
diff
changeset
|
235 parser.add_option('--no-geometry', action='store_true', |
8b307310cc1b
when KC launches SC to edit a sub, don't place the window right on the main SC window
drewp@bigasterisk.com
parents:
455
diff
changeset
|
236 help="don't save/restore window geometry") |
810 | 237 clientsession.add_option(parser) |
342
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
238 opts, args = parser.parse_args() |
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
239 |
0 | 240 root=tk.Tk() |
241 root.config(bg='black') | |
147 | 242 root.tk_setPalette("#004633") |
817
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
243 |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
244 initTkdnd(root.tk, 'tkdnd/trunk/') |
0 | 245 |
803 | 246 graph = SyncedGraph("subcomposer") |
810 | 247 session = clientsession.getUri('subcomposer', opts) |
803 | 248 |
817
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
249 if not opts.no_geometry: |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
250 toplevelat("subcomposer - %s" % opts.session, root, graph, session) |
6885c2fa9369
subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents:
810
diff
changeset
|
251 |
810 | 252 sc = Subcomposer(root, graph, session) |
0 | 253 sc.pack() |
254 | |
342
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
255 tk.Label(root,text="Bindings: B1 adjust level; B2 set full; B3 instant bump", |
228
9827df597f86
added help texts to subcomposer, curvecalc
drewp@bigasterisk.com
parents:
209
diff
changeset
|
256 font="Helvetica -12 italic",anchor='w').pack(side='top',fill='x') |
342
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
257 |
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
258 if len(args) == 1: |
458
8b307310cc1b
when KC launches SC to edit a sub, don't place the window right on the main SC window
drewp@bigasterisk.com
parents:
455
diff
changeset
|
259 root.config(bg='green') # trying to make these look distinctive |
342
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
260 sc.loadsub(args[0]) |
2c782ca93e73
subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents:
334
diff
changeset
|
261 sc.fill_both_boxes(args[0]) |
228
9827df597f86
added help texts to subcomposer, curvecalc
drewp@bigasterisk.com
parents:
209
diff
changeset
|
262 |
803 | 263 task.LoopingCall(sc.sendupdate).start(1) |
557
4e558643c952
subcomposer: squelch the exception we got every time we exited
David McClosky <dmcc@bigasterisk.com>
parents:
458
diff
changeset
|
264 |
810 | 265 root.protocol('WM_DELETE_WINDOW', reactor.stop) |
803 | 266 tksupport.install(root,ms=10) |
267 prof.run(reactor.run, profile=False) |