annotate bin/subcomposer @ 817:6885c2fa9369

subcomposer halfway to having the editchoice widget Ignore-this: 21eb05393c045298c173e0869371aaf9
author drewp@bigasterisk.com
date Thu, 01 Nov 2012 04:00:16 +0000
parents f29788d1c8c9
children bf728997bfde
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
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
2
45b12307c695 Initial revision
drewp
parents:
diff changeset
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
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
5 import Tkinter as tk
802
5442f5d8979a reformat
drewp@bigasterisk.com
parents: 729
diff changeset
6 import louie as dispatcher
803
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
7 from twisted.internet import reactor, tksupport, task
817
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
8 from rdflib import URIRef
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
9
209
1a84c5e83d3e dmxserver and subcomposer work in new layout
drewp@bigasterisk.com
parents: 201
diff changeset
10 import run_local
1a84c5e83d3e dmxserver and subcomposer work in new layout
drewp@bigasterisk.com
parents: 201
diff changeset
11 from light9.dmxchanedit import Levelbox
803
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
12 from light9 import dmxclient, Patch, Submaster, showconfig, prof
455
9dd2baa41cca subcomposer remembers window position
drewp@bigasterisk.com
parents: 450
diff changeset
13 from light9.uihelpers import toplevelat
803
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
14 from light9.rdfdb.syncedgraph import SyncedGraph
810
f29788d1c8c9 kc/sc session control
drewp@bigasterisk.com
parents: 804
diff changeset
15 from light9.rdfdb import clientsession
817
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
16 from light9.tkdnd import initTkdnd, dragSourceRegister, dropTargetRegister
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
17
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
18 class EditChoice(tk.Frame):
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
19 """
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
20 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
21 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
22 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
23 of resource; the caller does.
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
24 """
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
25 def __init__(self, parent, getResource, onSetResource, onSetLocal):
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
26 want to pass an observable uri value and an observable isLocal for 2way sync
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
27 """
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
28 getResource is called to get the URI of the currently
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
29 """
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
30 self.frame = tk.Frame(parent)
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
31 self.subSelection.pack(side='top')
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
32 tk.Label(self.subSelection, text="Editing:").pack(side='left')
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
33 self.currentSubFrame = tk.Frame(self.subSelection)
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
34 self.currentSubFrame.pack(side='left')
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
35
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
36 self.subIcon = tk.Label(self.currentSubFrame, text="sub1",
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
37 borderwidth=2,
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
38 relief='raised', padx=10, pady=10)
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
39 self.subIcon.pack()
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
40
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
41 dragSourceRegister(self.subIcon, 'copy', 'text/uri-list',
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
42 lambda: self.currentSub.uri)
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
43 def onEv(*args):
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
44 print "ev", args
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
45 return "link"
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
46 self.onEv = onEv
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
47
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
48 dropTargetRegister(self, onDrop=onEv,
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
49 hoverStyle=dict(background="#555500", bd=3, relief='groove'))
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
50
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
51 tk.Label(self.currentSubFrame, text="local data (drag sub here)").pack()
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
52 tk.Button(text="unlink", command=self.switchToLocalSub)
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
53
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
54
45b12307c695 Initial revision
drewp
parents:
diff changeset
55 class Subcomposer(tk.Frame):
817
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
56 """
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
57 <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
58 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
59 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
60
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
61 UI actions:
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
62 - 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
63
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
64 - button to clear the currentSub (putting it back to
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
65 sessionLocalSub, and also resetting sessionLocalSub to be empty
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
66 again)
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 - 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
69 session local sub is not easily addressable elsewhere
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 - 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
72 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
73 the new sub is named automatically, ideally something brief,
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
74 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
75 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
76 '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
77 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
78 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
79 sub's uri to a slug of the new label.
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
80
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
81 - 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
82 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
83 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
84 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
85 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
86 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
87 finders.
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
88
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
89 """
810
f29788d1c8c9 kc/sc session control
drewp@bigasterisk.com
parents: 804
diff changeset
90 def __init__(self, master, graph, session):
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
91 tk.Frame.__init__(self, master, bg='black')
803
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
92 self.graph = graph
810
f29788d1c8c9 kc/sc session control
drewp@bigasterisk.com
parents: 804
diff changeset
93 self.session = session
817
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
94 self.currentSub = Submaster.PersistentSubmaster(graph, URIRef('http://hello'))
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
95
803
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
96 self.levelbox = Levelbox(self, graph)
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
97 self.levelbox.pack(side='top')
45b12307c695 Initial revision
drewp
parents:
diff changeset
98
817
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
99 EditChoice(self).frame.pack(side='top')
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
100
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
101 def alltozero():
803
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
102 for lev in self.levelbox.levels:
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
103 lev.setlevel(0)
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
104
149
c31601504358 now with Subcomposer.open_sub_editing_window.
dmcc
parents: 147
diff changeset
105 tk.Button(self, text="all to zero", command=alltozero).pack(side='top')
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
106
803
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
107 dispatcher.connect(self.sendupdate, "levelchanged")
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
108
817
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
109 def switchToLocalSub(self, *args):
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
110 """
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
111 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
112 """
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
113
342
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
114 def fill_both_boxes(self, subname):
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
115 for box in [self.savebox, self.loadbox]:
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
116 box.set(subname)
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
117
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
118 def savenewsub(self, subname):
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
119 leveldict={}
45b12307c695 Initial revision
drewp
parents:
diff changeset
120 for i,lev in zip(range(len(self.levels)),self.levels):
45b12307c695 Initial revision
drewp
parents:
diff changeset
121 if lev!=0:
45b12307c695 Initial revision
drewp
parents:
diff changeset
122 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
123
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
124 s=Submaster.Submaster(subname,leveldict=leveldict)
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
125 s.save()
802
5442f5d8979a reformat
drewp@bigasterisk.com
parents: 729
diff changeset
126
810
f29788d1c8c9 kc/sc session control
drewp@bigasterisk.com
parents: 804
diff changeset
127 # 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
128 def loadsub(self, subname):
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
129 """puts a sub into the levels, replacing old level values"""
577
7ecde61ebff1 fix SC loading
drewp@bigasterisk.com
parents: 557
diff changeset
130 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
131 self.set_levels(s.get_dmx_list())
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
132 dispatcher.send("levelchanged")
802
5442f5d8979a reformat
drewp@bigasterisk.com
parents: 729
diff changeset
133
803
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
134 def toDmxLevels(self):
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
135 # the dmx levels we edit and output, range is 0..1 (dmx chan 1 is
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
136 # the 0 element)
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
137 out = {}
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
138 for lev in self.levelbox.levels:
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
139 out[lev.channelnum] = lev.currentlevel
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
140 if not out:
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
141 return []
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
142
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
143 return [out.get(i, 0) for i in range(max(out.keys()) + 1)]
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
144
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
145 def sendupdate(self):
803
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
146 dmxclient.outputlevels(self.toDmxLevels(), twisted=True)
802
5442f5d8979a reformat
drewp@bigasterisk.com
parents: 729
diff changeset
147
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
148
342
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
149 class EntryCommand(tk.Frame):
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
150 def __init__(self, master, verb="Save", cmd=None):
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
151 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
152 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
153 self.cmd = cmd
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
154 self.entry = tk.Entry(self)
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
155 self.entry.pack(side='left', expand=True, fill='x')
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
156
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
157 self.entry.bind("<Return>", self.action)
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
158 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
159
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
160 def action(self, *args):
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
161 subname = self.entry.get()
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
162 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
163 print "sub", self.cmd, subname
342
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
164
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
165 def set(self, text):
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
166 self.entry.delete(0, 'end')
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
167 self.entry.insert(0, text)
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
168
149
c31601504358 now with Subcomposer.open_sub_editing_window.
dmcc
parents: 147
diff changeset
169
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
170 #############################
45b12307c695 Initial revision
drewp
parents:
diff changeset
171
45b12307c695 Initial revision
drewp
parents:
diff changeset
172 if __name__ == "__main__":
342
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
173 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
174 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
175 help="don't save/restore window geometry")
810
f29788d1c8c9 kc/sc session control
drewp@bigasterisk.com
parents: 804
diff changeset
176 clientsession.add_option(parser)
342
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
177 opts, args = parser.parse_args()
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
178
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
179 root=tk.Tk()
45b12307c695 Initial revision
drewp
parents:
diff changeset
180 root.config(bg='black')
147
6a1f4becb1db merged some late color change edits from the theater
drewp
parents: 144
diff changeset
181 root.tk_setPalette("#004633")
817
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
182
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
183 initTkdnd(root.tk, 'tkdnd/trunk/')
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
184
803
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
185 graph = SyncedGraph("subcomposer")
810
f29788d1c8c9 kc/sc session control
drewp@bigasterisk.com
parents: 804
diff changeset
186 session = clientsession.getUri('subcomposer', opts)
803
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
187
817
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
188 if not opts.no_geometry:
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
189 toplevelat("subcomposer - %s" % opts.session, root, graph, session)
6885c2fa9369 subcomposer halfway to having the editchoice widget
drewp@bigasterisk.com
parents: 810
diff changeset
190
810
f29788d1c8c9 kc/sc session control
drewp@bigasterisk.com
parents: 804
diff changeset
191 sc = Subcomposer(root, graph, session)
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
192 sc.pack()
45b12307c695 Initial revision
drewp
parents:
diff changeset
193
342
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
194 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
195 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
196
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
197 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
198 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
199 sc.loadsub(args[0])
2c782ca93e73 subcomposer takes sub name on cmdline
Drew Perttula <drewp@bigasterisk.com>
parents: 334
diff changeset
200 sc.fill_both_boxes(args[0])
228
9827df597f86 added help texts to subcomposer, curvecalc
drewp@bigasterisk.com
parents: 209
diff changeset
201
803
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
202 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
203
810
f29788d1c8c9 kc/sc session control
drewp@bigasterisk.com
parents: 804
diff changeset
204 root.protocol('WM_DELETE_WINDOW', reactor.stop)
803
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
205 tksupport.install(root,ms=10)
ce4fffe8e413 update SC to read rdf graph
drewp@bigasterisk.com
parents: 802
diff changeset
206 prof.run(reactor.run, profile=False)