Files
@ 6504df2aee03
Branch filter:
Location: light9/bin/subcomposer - annotation
6504df2aee03
7.1 KiB
text/plain
show 2013 data
Ignore-this: a36a24c7a2a13ae4f4088f57a97e14a0
Ignore-this: a36a24c7a2a13ae4f4088f57a97e14a0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | b5efddd80dad 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 1a84c5e83d3e 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 1a84c5e83d3e 321fc6150ee3 2c782ca93e73 0f7e99d02dc6 1a84c5e83d3e 5442f5d8979a ce4fffe8e413 167a61d3cfbf 1a84c5e83d3e bdfdfea84510 167a61d3cfbf 167a61d3cfbf 1a84c5e83d3e 167a61d3cfbf 167a61d3cfbf 9dd2baa41cca ce4fffe8e413 f29788d1c8c9 f987eb9c3672 f987eb9c3672 167a61d3cfbf f987eb9c3672 f987eb9c3672 bf728997bfde 1a84c5e83d3e 1a84c5e83d3e 6885c2fa9369 6885c2fa9369 6885c2fa9369 6885c2fa9369 6885c2fa9369 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 bf728997bfde bf728997bfde 321fc6150ee3 6885c2fa9369 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 bf728997bfde 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 6885c2fa9369 6885c2fa9369 f29788d1c8c9 1a84c5e83d3e ce4fffe8e413 f29788d1c8c9 1a84c5e83d3e 4b3d7e8ba24a 4b3d7e8ba24a 1a84c5e83d3e 4b3d7e8ba24a 4b3d7e8ba24a 4b3d7e8ba24a bf728997bfde bf728997bfde f987eb9c3672 f987eb9c3672 bf728997bfde 321fc6150ee3 4b3d7e8ba24a 167a61d3cfbf 4b3d7e8ba24a 321fc6150ee3 167a61d3cfbf 321fc6150ee3 321fc6150ee3 321fc6150ee3 bf728997bfde 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 1a84c5e83d3e 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 1a84c5e83d3e 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 1a84c5e83d3e 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 167a61d3cfbf 167a61d3cfbf 167a61d3cfbf 167a61d3cfbf 167a61d3cfbf 321fc6150ee3 321fc6150ee3 167a61d3cfbf 321fc6150ee3 6885c2fa9369 321fc6150ee3 321fc6150ee3 2c782ca93e73 a6662d61ebcd 1a84c5e83d3e 1a84c5e83d3e 1a84c5e83d3e 167a61d3cfbf 2c782ca93e73 a6662d61ebcd 1a84c5e83d3e 5442f5d8979a 1a84c5e83d3e 321fc6150ee3 321fc6150ee3 5442f5d8979a 1a84c5e83d3e 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 bf728997bfde 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 321fc6150ee3 f987eb9c3672 f987eb9c3672 2c782ca93e73 321fc6150ee3 2c782ca93e73 1a84c5e83d3e 1a84c5e83d3e 1a84c5e83d3e 1a84c5e83d3e 321fc6150ee3 8b307310cc1b 8b307310cc1b f29788d1c8c9 2c782ca93e73 2c782ca93e73 1a84c5e83d3e 1a84c5e83d3e 1a84c5e83d3e 6885c2fa9369 6885c2fa9369 1a84c5e83d3e ce4fffe8e413 f29788d1c8c9 ce4fffe8e413 321fc6150ee3 4e558643c952 f29788d1c8c9 ce4fffe8e413 ce4fffe8e413 | #!bin/python
"""
subcomposer
session
observable(currentSub), a Submaster which tracks the graph
EditChoice widget
can change currentSub to another sub
Levelbox widget
watch observable(currentSub) for a new sub, and also watch currentSub for edits to push to the OneLevel widgets
OneLevel widget
UI edits are caught here and go all the way back to currentSub
"""
from __future__ import division, nested_scopes
import time, logging
from optparse import OptionParser
import logging
import Tkinter as tk
import louie as dispatcher
from twisted.internet import reactor, tksupport, task
from rdflib import URIRef, RDF
from run_local import log
log.setLevel(logging.DEBUG)
from light9.dmxchanedit import Levelbox
from light9 import dmxclient, Submaster, prof
from light9.Patch import get_channel_name
from light9.uihelpers import toplevelat
from light9.rdfdb.syncedgraph import SyncedGraph
from light9.rdfdb import clientsession
from light9.tkdnd import initTkdnd
from light9.namespaces import L9
from light9.rdfdb.patch import Patch
from light9.observable import Observable
from light9.editchoice import EditChoice, Local
class Subcomposer(tk.Frame):
"""
<session> l9:currentSub ?sub is the URI of the sub we're tied to for displaying and
editing. If we don't have a currentSub, then we're actually
editing a session-local sub called <session> l9:currentSub <sessionLocalSub>
I'm not sure that Locals should even be PersistentSubmaster with
uri and graph storage, but I think that way is making fewer
special cases.
Contains an EditChoice widget
Dependencies:
graph (?session :currentSub ?s) -> self.currentSub
self.currentSub -> graph
self.currentSub -> self._currentChoice (which might be Local)
self._currentChoice (which might be Local) -> self.currentSub
inside the current sub:
graph -> Submaster levels (handled in Submaster)
Submaster levels -> OneLevel widget
OneLevel widget -> Submaster.editLevel
Submaster.editLevel -> graph (handled in Submaster)
"""
def __init__(self, master, graph, session):
tk.Frame.__init__(self, master, bg='black')
self.graph = graph
self.session = session
# this is a URIRef or Local
self._currentChoice = Observable(Local)
# this is a PersistentSubmaster (even for local)
self.currentSub = Observable(Submaster.PersistentSubmaster(
graph, self.makeLocal()))
def pc(val):
log.info("change viewed sub to %s", val)
self._currentChoice.subscribe(pc)
EditChoice(self, self.graph, self._currentChoice).frame.pack(side='top')
self.setupSubChoiceLinks()
self.setupLevelboxUi()
def setupSubChoiceLinks(self):
graph = self.graph
def ann():
print "currently: session=%s currentSub=%r _currentChoice=%r" % (
self.session, self.currentSub(), self._currentChoice())
@graph.addHandler
def graphChanged():
s = graph.value(self.session, L9['currentSub'])
if s is None:
s = self.makeLocal()
self.currentSub(Submaster.PersistentSubmaster(graph, s))
@self.currentSub.subscribe
def subChanged(newSub):
if newSub is None:
graph.patchObject(self.session,
self.session, L9['currentSub'], None)
return
self.sendupdate()
graph.patchObject(self.session,
self.session, L9['currentSub'], newSub.uri)
if newSub and 'local' in newSub.uri: # wrong- use rdf:type or something?
self._currentChoice(Local)
else:
# i think right here is the point that the last local
# becomes garbage, and we could clean it up.
self._currentChoice(newSub.uri)
dispatcher.connect(self.levelsChanged, "sub levels changed")
@self._currentChoice.subscribe
def choiceChanged(newChoice):
if newChoice is Local:
newChoice = self.makeLocal()
if newChoice is not None:
self.currentSub(Submaster.PersistentSubmaster(
graph, newChoice))
def levelsChanged(self, sub):
if sub == self.currentSub():
self.sendupdate()
def makeLocal(self):
# todo: put a type on this, so subChanged can identify it right
# todo: where will these get stored, or are they local to this
# subcomposer process and don't use PersistentSubmaster at all?
new = URIRef("http://local/%s" % time.time())
self.graph.patch(Patch(addQuads=[(new, RDF.type, L9['Submaster'], self.session)]))
return new
def setupLevelboxUi(self):
self.levelbox = Levelbox(self, self.graph, self.currentSub)
self.levelbox.pack(side='top')
tk.Button(self, text="All to zero",
command=lambda *args: self.currentSub().clear()).pack(side='top')
def savenewsub(self, subname):
leveldict={}
for i,lev in zip(range(len(self.levels)),self.levels):
if lev!=0:
leveldict[get_channel_name(i+1)]=lev
s=Submaster.Submaster(subname,leveldict=leveldict)
s.save()
def sendupdate(self):
d = self.currentSub().get_dmx_list()
dmxclient.outputlevels(d, twisted=True)
def launch(opts, args, root, graph, session):
if not opts.no_geometry:
toplevelat("subcomposer - %s" % opts.session, root, graph, session)
sc = Subcomposer(root, graph, session)
sc.pack()
tk.Label(root,text="Bindings: B1 adjust level; B2 set full; B3 instant bump",
font="Helvetica -12 italic",anchor='w').pack(side='top',fill='x')
if len(args) == 1:
# it might be a little too weird that cmdline arg to this
# process changes anything else in the same session. But also
# I'm not sure who would ever make 2 subcomposers of the same
# session (except when quitting and restarting, to get the
# same window pos), so maybe it doesn't matter. But still,
# this tool should probably default to making new sessions
# usually instead of loading the same one
graph.patchObject(session,
session, L9['currentSub'], URIRef(args[0]))
task.LoopingCall(sc.sendupdate).start(10)
#############################
if __name__ == "__main__":
parser = OptionParser(usage="%prog [suburi]")
parser.add_option('--no-geometry', action='store_true',
help="don't save/restore window geometry")
clientsession.add_option(parser)
opts, args = parser.parse_args()
root=tk.Tk()
root.config(bg='black')
root.tk_setPalette("#004633")
initTkdnd(root.tk, 'tkdnd/trunk/')
graph = SyncedGraph("subcomposer")
session = clientsession.getUri('subcomposer', opts)
graph.initiallySynced.addCallback(lambda _: launch(opts, args, root, graph, session))
root.protocol('WM_DELETE_WINDOW', reactor.stop)
tksupport.install(root,ms=10)
prof.run(reactor.run, profile=False)
|