Mercurial > code > home > repos > light9
comparison bin/subcomposer @ 874:167a61d3cfbf
subcomposer put local subs into the graph with a type edge.
Ignore-this: a0c1ef69684786e4758b9ecf10927d3b
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Thu, 06 Jun 2013 08:23:17 +0000 |
parents | 4b3d7e8ba24a |
children | e09e3d1d83d5 |
comparison
equal
deleted
inserted
replaced
873:f6e4faa0422b | 874:167a61d3cfbf |
---|---|
20 from optparse import OptionParser | 20 from optparse import OptionParser |
21 import logging | 21 import logging |
22 import Tkinter as tk | 22 import Tkinter as tk |
23 import louie as dispatcher | 23 import louie as dispatcher |
24 from twisted.internet import reactor, tksupport, task | 24 from twisted.internet import reactor, tksupport, task |
25 from rdflib import URIRef | 25 from rdflib import URIRef, RDF |
26 | 26 |
27 from run_local import log | 27 from run_local import log |
28 log.setLevel(logging.DEBUG) | |
29 | |
28 from light9.dmxchanedit import Levelbox | 30 from light9.dmxchanedit import Levelbox |
29 from light9 import dmxclient, Patch, Submaster, prof | 31 from light9 import dmxclient, Submaster, prof |
32 from light9.Patch import get_channel_name | |
30 from light9.uihelpers import toplevelat | 33 from light9.uihelpers import toplevelat |
31 from light9.rdfdb.syncedgraph import SyncedGraph | 34 from light9.rdfdb.syncedgraph import SyncedGraph |
32 from light9.rdfdb import clientsession | 35 from light9.rdfdb import clientsession |
33 from light9.tkdnd import initTkdnd | 36 from light9.tkdnd import initTkdnd |
34 from light9.namespaces import L9 | 37 from light9.namespaces import L9 |
38 from light9.rdfdb.patch import Patch | |
35 from light9.observable import Observable | 39 from light9.observable import Observable |
36 from light9.editchoice import EditChoice, Local | 40 from light9.editchoice import EditChoice, Local |
37 | 41 |
38 | 42 |
39 class Subcomposer(tk.Frame): | 43 class Subcomposer(tk.Frame): |
78 log.info("change viewed sub to %s", val) | 82 log.info("change viewed sub to %s", val) |
79 self._currentChoice.subscribe(pc) | 83 self._currentChoice.subscribe(pc) |
80 | 84 |
81 EditChoice(self, self.graph, self._currentChoice).frame.pack(side='top') | 85 EditChoice(self, self.graph, self._currentChoice).frame.pack(side='top') |
82 self.setupSubChoiceLinks() | 86 self.setupSubChoiceLinks() |
87 self.setupLevelboxUi() | |
83 | 88 |
84 def setupSubChoiceLinks(self): | 89 def setupSubChoiceLinks(self): |
85 | 90 graph = self.graph |
86 def ann(): | 91 def ann(): |
87 print "currently: session=%s currentSub=%r _currentChoice=%r" % ( | 92 print "currently: session=%s currentSub=%r _currentChoice=%r" % ( |
88 self.session, self.currentSub(), self._currentChoice()) | 93 self.session, self.currentSub(), self._currentChoice()) |
89 | 94 |
90 @graph.addHandler | 95 @graph.addHandler |
127 | 132 |
128 def makeLocal(self): | 133 def makeLocal(self): |
129 # todo: put a type on this, so subChanged can identify it right | 134 # todo: put a type on this, so subChanged can identify it right |
130 # todo: where will these get stored, or are they local to this | 135 # todo: where will these get stored, or are they local to this |
131 # subcomposer process and don't use PersistentSubmaster at all? | 136 # subcomposer process and don't use PersistentSubmaster at all? |
132 return URIRef("http://local/%s" % time.time()) | 137 |
138 new = URIRef("http://local/%s" % time.time()) | |
139 self.graph.patch(Patch(addQuads=[(new, RDF.type, L9['Submaster'], self.session)])) | |
140 | |
141 return new | |
133 | 142 |
134 def setupLevelboxUi(self): | 143 def setupLevelboxUi(self): |
135 self.levelbox = Levelbox(self, graph, self.currentSub) | 144 self.levelbox = Levelbox(self, self.graph, self.currentSub) |
136 self.levelbox.pack(side='top') | 145 self.levelbox.pack(side='top') |
137 | 146 |
138 tk.Button(self, text="All to zero", | 147 tk.Button(self, text="All to zero", |
139 command=lambda *args: self.currentSub().clear()).pack(side='top') | 148 command=lambda *args: self.currentSub().clear()).pack(side='top') |
140 | 149 |
141 def savenewsub(self, subname): | 150 def savenewsub(self, subname): |
142 leveldict={} | 151 leveldict={} |
143 for i,lev in zip(range(len(self.levels)),self.levels): | 152 for i,lev in zip(range(len(self.levels)),self.levels): |
144 if lev!=0: | 153 if lev!=0: |
145 leveldict[Patch.get_channel_name(i+1)]=lev | 154 leveldict[get_channel_name(i+1)]=lev |
146 | 155 |
147 s=Submaster.Submaster(subname,leveldict=leveldict) | 156 s=Submaster.Submaster(subname,leveldict=leveldict) |
148 s.save() | 157 s.save() |
149 | 158 |
150 def sendupdate(self): | 159 def sendupdate(self): |
183 parser.add_option('--no-geometry', action='store_true', | 192 parser.add_option('--no-geometry', action='store_true', |
184 help="don't save/restore window geometry") | 193 help="don't save/restore window geometry") |
185 clientsession.add_option(parser) | 194 clientsession.add_option(parser) |
186 opts, args = parser.parse_args() | 195 opts, args = parser.parse_args() |
187 | 196 |
188 logging.basicConfig(level=logging.DEBUG) | |
189 | |
190 root=tk.Tk() | 197 root=tk.Tk() |
191 root.config(bg='black') | 198 root.config(bg='black') |
192 root.tk_setPalette("#004633") | 199 root.tk_setPalette("#004633") |
193 | 200 |
194 initTkdnd(root.tk, 'tkdnd/trunk/') | 201 initTkdnd(root.tk, 'tkdnd/trunk/') |