annotate bin/subcomposer @ 901:0dacbba70d06 last-2012

remove some broken profiler attempts Ignore-this: 3d50124a16807ee922e85911d510ce58
author Drew Perttula <drewp@bigasterisk.com>
date Mon, 10 Jun 2013 00:09:17 +0000
parents e09e3d1d83d5
children 4b9997ab0e4f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
729
b5efddd80dad update more shbang lines
Drew Perttula <drewp@bigasterisk.com>
parents: 577
diff changeset
1 #!bin/python
838
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
2 """
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
3 subcomposer
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
4 session
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
5 observable(currentSub), a Submaster which tracks the graph
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
6
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
7 EditChoice widget
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
8 can change currentSub to another sub
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
9
838
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
10 Levelbox widget
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
11 watch observable(currentSub) for a new sub, and also watch currentSub for edits to push to the OneLevel widgets
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
12
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
13 OneLevel widget
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
14 UI edits are caught here and go all the way back to currentSub
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
15
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
16
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
17 """
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
18 from __future__ import division, nested_scopes
838
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
19 import time, logging
342
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
20 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
21 import logging
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
22 import Tkinter as tk
802
5442f5d8979a reformat
drewp@bigasterisk.com
parents: 729
diff changeset
23 import louie as dispatcher
803
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
24 from twisted.internet import reactor, tksupport, task
874
167a61d3cfbf subcomposer put local subs into the graph with a type edge.
Drew Perttula <drewp@bigasterisk.com>
parents: 867
diff changeset
25 from rdflib import URIRef, RDF
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
26
833
bdfdfea84510 colored logs
Drew Perttula <drewp@bigasterisk.com>
parents: 831
diff changeset
27 from run_local import log
874
167a61d3cfbf subcomposer put local subs into the graph with a type edge.
Drew Perttula <drewp@bigasterisk.com>
parents: 867
diff changeset
28 log.setLevel(logging.DEBUG)
167a61d3cfbf subcomposer put local subs into the graph with a type edge.
Drew Perttula <drewp@bigasterisk.com>
parents: 867
diff changeset
29
209
1a84c5e83d3e dmxserver and subcomposer work in new layout
drewp@bigasterisk.com
parents: 201
diff changeset
30 from light9.dmxchanedit import Levelbox
874
167a61d3cfbf subcomposer put local subs into the graph with a type edge.
Drew Perttula <drewp@bigasterisk.com>
parents: 867
diff changeset
31 from light9 import dmxclient, Submaster, prof
167a61d3cfbf subcomposer put local subs into the graph with a type edge.
Drew Perttula <drewp@bigasterisk.com>
parents: 867
diff changeset
32 from light9.Patch import get_channel_name
455
9dd2baa41cca subcomposer remembers window position
drewp@bigasterisk.com
parents: 450
diff changeset
33 from light9.uihelpers import toplevelat
803
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
34 from light9.rdfdb.syncedgraph import SyncedGraph
810
f29788d1c8c9 kc/sc session control
drewp@bigasterisk.com
parents: 804
diff changeset
35 from light9.rdfdb import clientsession
850
f987eb9c3672 subcomposer code merge
drewp@bigasterisk.com
parents: 838
diff changeset
36 from light9.tkdnd import initTkdnd
f987eb9c3672 subcomposer code merge
drewp@bigasterisk.com
parents: 838
diff changeset
37 from light9.namespaces import L9
874
167a61d3cfbf subcomposer put local subs into the graph with a type edge.
Drew Perttula <drewp@bigasterisk.com>
parents: 867
diff changeset
38 from light9.rdfdb.patch import Patch
850
f987eb9c3672 subcomposer code merge
drewp@bigasterisk.com
parents: 838
diff changeset
39 from light9.observable import Observable
f987eb9c3672 subcomposer code merge
drewp@bigasterisk.com
parents: 838
diff changeset
40 from light9.editchoice import EditChoice, Local
818
bf728997bfde start the observable between editchoice and the editor
drewp@bigasterisk.com
parents: 817
diff changeset
41
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
42
45b12307c695 Initial revision
drewp
parents:
diff changeset
43 class Subcomposer(tk.Frame):
817
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
44 """
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
45 <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
46 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
47 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
48
838
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
49 I'm not sure that Locals should even be PersistentSubmaster with
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
50 uri and graph storage, but I think that way is making fewer
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
51 special cases.
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
52
818
bf728997bfde start the observable between editchoice and the editor
drewp@bigasterisk.com
parents: 817
diff changeset
53 Contains an EditChoice widget
bf728997bfde start the observable between editchoice and the editor
drewp@bigasterisk.com
parents: 817
diff changeset
54
838
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
55 Dependencies:
817
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
56
838
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
57 graph (?session :currentSub ?s) -> self.currentSub
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
58 self.currentSub -> graph
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
59 self.currentSub -> self._currentChoice (which might be Local)
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
60 self._currentChoice (which might be Local) -> self.currentSub
818
bf728997bfde start the observable between editchoice and the editor
drewp@bigasterisk.com
parents: 817
diff changeset
61
838
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
62 inside the current sub:
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
63 graph -> Submaster levels (handled in Submaster)
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
64 Submaster levels -> OneLevel widget
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
65 OneLevel widget -> Submaster.editLevel
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
66 Submaster.editLevel -> graph (handled in Submaster)
817
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
67
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
68 """
810
f29788d1c8c9 kc/sc session control
drewp@bigasterisk.com
parents: 804
diff changeset
69 def __init__(self, master, graph, session):
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
70 tk.Frame.__init__(self, master, bg='black')
803
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
71 self.graph = graph
810
f29788d1c8c9 kc/sc session control
drewp@bigasterisk.com
parents: 804
diff changeset
72 self.session = session
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
73
867
4b3d7e8ba24a subcomposer is nicer if we always have some Submaster object. and if you call all the init code
Drew Perttula <drewp@bigasterisk.com>
parents: 850
diff changeset
74 # this is a URIRef or Local
4b3d7e8ba24a subcomposer is nicer if we always have some Submaster object. and if you call all the init code
Drew Perttula <drewp@bigasterisk.com>
parents: 850
diff changeset
75 self._currentChoice = Observable(Local)
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
76
867
4b3d7e8ba24a subcomposer is nicer if we always have some Submaster object. and if you call all the init code
Drew Perttula <drewp@bigasterisk.com>
parents: 850
diff changeset
77 # this is a PersistentSubmaster (even for local)
4b3d7e8ba24a subcomposer is nicer if we always have some Submaster object. and if you call all the init code
Drew Perttula <drewp@bigasterisk.com>
parents: 850
diff changeset
78 self.currentSub = Observable(Submaster.PersistentSubmaster(
4b3d7e8ba24a subcomposer is nicer if we always have some Submaster object. and if you call all the init code
Drew Perttula <drewp@bigasterisk.com>
parents: 850
diff changeset
79 graph, self.makeLocal()))
818
bf728997bfde start the observable between editchoice and the editor
drewp@bigasterisk.com
parents: 817
diff changeset
80
bf728997bfde start the observable between editchoice and the editor
drewp@bigasterisk.com
parents: 817
diff changeset
81 def pc(val):
850
f987eb9c3672 subcomposer code merge
drewp@bigasterisk.com
parents: 838
diff changeset
82 log.info("change viewed sub to %s", val)
f987eb9c3672 subcomposer code merge
drewp@bigasterisk.com
parents: 838
diff changeset
83 self._currentChoice.subscribe(pc)
818
bf728997bfde start the observable between editchoice and the editor
drewp@bigasterisk.com
parents: 817
diff changeset
84
838
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
85 EditChoice(self, self.graph, self._currentChoice).frame.pack(side='top')
867
4b3d7e8ba24a subcomposer is nicer if we always have some Submaster object. and if you call all the init code
Drew Perttula <drewp@bigasterisk.com>
parents: 850
diff changeset
86 self.setupSubChoiceLinks()
874
167a61d3cfbf subcomposer put local subs into the graph with a type edge.
Drew Perttula <drewp@bigasterisk.com>
parents: 867
diff changeset
87 self.setupLevelboxUi()
867
4b3d7e8ba24a subcomposer is nicer if we always have some Submaster object. and if you call all the init code
Drew Perttula <drewp@bigasterisk.com>
parents: 850
diff changeset
88
838
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
89 def setupSubChoiceLinks(self):
874
167a61d3cfbf subcomposer put local subs into the graph with a type edge.
Drew Perttula <drewp@bigasterisk.com>
parents: 867
diff changeset
90 graph = self.graph
838
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
91 def ann():
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
92 print "currently: session=%s currentSub=%r _currentChoice=%r" % (
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
93 self.session, self.currentSub(), self._currentChoice())
818
bf728997bfde start the observable between editchoice and the editor
drewp@bigasterisk.com
parents: 817
diff changeset
94
838
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
95 @graph.addHandler
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
96 def graphChanged():
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
97 s = graph.value(self.session, L9['currentSub'])
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
98 if s is None:
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
99 s = self.makeLocal()
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
100 self.currentSub(Submaster.PersistentSubmaster(graph, s))
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
101
838
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
102 @self.currentSub.subscribe
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
103 def subChanged(newSub):
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
104 if newSub is None:
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
105 graph.patchObject(self.session,
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
106 self.session, L9['currentSub'], None)
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
107 return
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
108 self.sendupdate()
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
109 graph.patchObject(self.session,
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
110 self.session, L9['currentSub'], newSub.uri)
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
111
880
e09e3d1d83d5 slightly better behavior when the graph is out of sync. add LocalSubmaster type
drewp@bigasterisk.com
parents: 874
diff changeset
112 with graph.currentState() as current:
e09e3d1d83d5 slightly better behavior when the graph is out of sync. add LocalSubmaster type
drewp@bigasterisk.com
parents: 874
diff changeset
113
e09e3d1d83d5 slightly better behavior when the graph is out of sync. add LocalSubmaster type
drewp@bigasterisk.com
parents: 874
diff changeset
114 if newSub and (newSub.uri, RDF.type, L9['LocalSubmaster']) in current:
e09e3d1d83d5 slightly better behavior when the graph is out of sync. add LocalSubmaster type
drewp@bigasterisk.com
parents: 874
diff changeset
115 self._currentChoice(Local)
e09e3d1d83d5 slightly better behavior when the graph is out of sync. add LocalSubmaster type
drewp@bigasterisk.com
parents: 874
diff changeset
116 else:
e09e3d1d83d5 slightly better behavior when the graph is out of sync. add LocalSubmaster type
drewp@bigasterisk.com
parents: 874
diff changeset
117 # i think right here is the point that the last local
e09e3d1d83d5 slightly better behavior when the graph is out of sync. add LocalSubmaster type
drewp@bigasterisk.com
parents: 874
diff changeset
118 # becomes garbage, and we could clean it up.
e09e3d1d83d5 slightly better behavior when the graph is out of sync. add LocalSubmaster type
drewp@bigasterisk.com
parents: 874
diff changeset
119 self._currentChoice(newSub.uri)
838
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
120
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
121 dispatcher.connect(self.levelsChanged, "sub levels changed")
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
122
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
123 @self._currentChoice.subscribe
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
124 def choiceChanged(newChoice):
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
125 if newChoice is Local:
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
126 newChoice = self.makeLocal()
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
127 if newChoice is not None:
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
128 self.currentSub(Submaster.PersistentSubmaster(
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
129 graph, newChoice))
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
130
838
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
131 def levelsChanged(self, sub):
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
132 if sub == self.currentSub():
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
133 self.sendupdate()
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
134
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
135 def makeLocal(self):
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
136 # todo: put a type on this, so subChanged can identify it right
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
137 # todo: where will these get stored, or are they local to this
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
138 # subcomposer process and don't use PersistentSubmaster at all?
874
167a61d3cfbf subcomposer put local subs into the graph with a type edge.
Drew Perttula <drewp@bigasterisk.com>
parents: 867
diff changeset
139
167a61d3cfbf subcomposer put local subs into the graph with a type edge.
Drew Perttula <drewp@bigasterisk.com>
parents: 867
diff changeset
140 new = URIRef("http://local/%s" % time.time())
880
e09e3d1d83d5 slightly better behavior when the graph is out of sync. add LocalSubmaster type
drewp@bigasterisk.com
parents: 874
diff changeset
141 self.graph.patch(Patch(addQuads=[
e09e3d1d83d5 slightly better behavior when the graph is out of sync. add LocalSubmaster type
drewp@bigasterisk.com
parents: 874
diff changeset
142 (new, RDF.type, L9['Submaster'], self.session),
e09e3d1d83d5 slightly better behavior when the graph is out of sync. add LocalSubmaster type
drewp@bigasterisk.com
parents: 874
diff changeset
143 (new, RDF.type, L9['LocalSubmaster'], self.session),
e09e3d1d83d5 slightly better behavior when the graph is out of sync. add LocalSubmaster type
drewp@bigasterisk.com
parents: 874
diff changeset
144 ]))
874
167a61d3cfbf subcomposer put local subs into the graph with a type edge.
Drew Perttula <drewp@bigasterisk.com>
parents: 867
diff changeset
145
167a61d3cfbf subcomposer put local subs into the graph with a type edge.
Drew Perttula <drewp@bigasterisk.com>
parents: 867
diff changeset
146 return new
838
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
147
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
148 def setupLevelboxUi(self):
874
167a61d3cfbf subcomposer put local subs into the graph with a type edge.
Drew Perttula <drewp@bigasterisk.com>
parents: 867
diff changeset
149 self.levelbox = Levelbox(self, self.graph, self.currentSub)
838
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
150 self.levelbox.pack(side='top')
817
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
151
838
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
152 tk.Button(self, text="All to zero",
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
153 command=lambda *args: self.currentSub().clear()).pack(side='top')
342
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
154
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
155 def savenewsub(self, subname):
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
156 leveldict={}
45b12307c695 Initial revision
drewp
parents:
diff changeset
157 for i,lev in zip(range(len(self.levels)),self.levels):
45b12307c695 Initial revision
drewp
parents:
diff changeset
158 if lev!=0:
874
167a61d3cfbf subcomposer put local subs into the graph with a type edge.
Drew Perttula <drewp@bigasterisk.com>
parents: 867
diff changeset
159 leveldict[get_channel_name(i+1)]=lev
342
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
160
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
161 s=Submaster.Submaster(subname,leveldict=leveldict)
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
162 s.save()
802
5442f5d8979a reformat
drewp@bigasterisk.com
parents: 729
diff changeset
163
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
164 def sendupdate(self):
838
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
165 d = self.currentSub().get_dmx_list()
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
166 dmxclient.outputlevels(d, twisted=True)
802
5442f5d8979a reformat
drewp@bigasterisk.com
parents: 729
diff changeset
167
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
168
838
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
169 def launch(opts, args, root, graph, session):
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
170 if not opts.no_geometry:
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
171 toplevelat("subcomposer - %s" % opts.session, root, graph, session)
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
172
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
173 sc = Subcomposer(root, graph, session)
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
174 sc.pack()
818
bf728997bfde start the observable between editchoice and the editor
drewp@bigasterisk.com
parents: 817
diff changeset
175
838
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
176 tk.Label(root,text="Bindings: B1 adjust level; B2 set full; B3 instant bump",
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
177 font="Helvetica -12 italic",anchor='w').pack(side='top',fill='x')
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
178
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
179 if len(args) == 1:
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
180 # it might be a little too weird that cmdline arg to this
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
181 # process changes anything else in the same session. But also
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
182 # I'm not sure who would ever make 2 subcomposers of the same
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
183 # session (except when quitting and restarting, to get the
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
184 # same window pos), so maybe it doesn't matter. But still,
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
185 # this tool should probably default to making new sessions
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
186 # usually instead of loading the same one
850
f987eb9c3672 subcomposer code merge
drewp@bigasterisk.com
parents: 838
diff changeset
187 graph.patchObject(session,
f987eb9c3672 subcomposer code merge
drewp@bigasterisk.com
parents: 838
diff changeset
188 session, L9['currentSub'], URIRef(args[0]))
342
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
189
838
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
190 task.LoopingCall(sc.sendupdate).start(10)
342
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
191
149
c31601504358 now with Subcomposer.open_sub_editing_window.
dmcc
parents: 147
diff changeset
192
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
193 #############################
45b12307c695 Initial revision
drewp
parents:
diff changeset
194
45b12307c695 Initial revision
drewp
parents:
diff changeset
195 if __name__ == "__main__":
838
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
196 parser = OptionParser(usage="%prog [suburi]")
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
197 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
198 help="don't save/restore window geometry")
810
f29788d1c8c9 kc/sc session control
drewp@bigasterisk.com
parents: 804
diff changeset
199 clientsession.add_option(parser)
342
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
200 opts, args = parser.parse_args()
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
201
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
202 root=tk.Tk()
45b12307c695 Initial revision
drewp
parents:
diff changeset
203 root.config(bg='black')
147
6a1f4becb1db merged some late color change edits from the theater
drewp
parents: 144
diff changeset
204 root.tk_setPalette("#004633")
817
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
205
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
206 initTkdnd(root.tk, 'tkdnd/trunk/')
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
207
803
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
208 graph = SyncedGraph("subcomposer")
810
f29788d1c8c9 kc/sc session control
drewp@bigasterisk.com
parents: 804
diff changeset
209 session = clientsession.getUri('subcomposer', opts)
803
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
210
838
321fc6150ee3 subcomposer's nice currently-editing DnD box
drewp@bigasterisk.com
parents: 834
diff changeset
211 graph.initiallySynced.addCallback(lambda _: launch(opts, args, root, graph, session))
557
4e558643c952 subcomposer: squelch the exception we got every time we exited
David McClosky <dmcc@bigasterisk.com>
parents: 458
diff changeset
212
810
f29788d1c8c9 kc/sc session control
drewp@bigasterisk.com
parents: 804
diff changeset
213 root.protocol('WM_DELETE_WINDOW', reactor.stop)
803
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
214 tksupport.install(root,ms=10)
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
215 prof.run(reactor.run, profile=False)