Mercurial > code > home > repos > light9
comparison bin/curvecalc @ 692:ccdd04f4ca7d
subterm display is working
Ignore-this: 54254c7f9d6cd89bd80031ed1cf92066
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Fri, 08 Jun 2012 05:11:41 +0000 |
parents | 62d83d456f2e |
children | 34dacd800505 |
comparison
equal
deleted
inserted
replaced
691:62d83d456f2e | 692:ccdd04f4ca7d |
---|---|
51 l.pack(side='top',fill='x') | 51 l.pack(side='top',fill='x') |
52 dispatcher.connect(lambda val,l=l,sn=signame,tf=textfilter: | 52 dispatcher.connect(lambda val,l=l,sn=signame,tf=textfilter: |
53 l.config(text=sn+": "+tf(val)), | 53 l.config(text=sn+": "+tf(val)), |
54 signame, weak=False) | 54 signame, weak=False) |
55 | 55 |
56 def add_subterms_for_song(graph, song, curveset, subterms, master): | |
57 for st in graph.objects(song, L9['subterm']): | |
58 log.info("song %s has subterm %s", song, st) | |
59 try: | |
60 add_one_subterm(graph, graph.value(st, L9['sub']), curveset, | |
61 subterms, master, graph.value(st, L9['expression'])) | |
62 except rdflib.exceptions.UniquenessError: | |
63 print "working around curvecalc save corruption" | |
64 # curvecalc put all the expressions on one subterm, which is wrong | |
65 for expr in graph.objects(st, L9['expression']): | |
66 add_one_subterm(graph, graph.value(st, L9['sub']), | |
67 curveset, subterms, master, expr) | |
68 | |
69 | 56 |
70 def makeGraph(): | 57 def makeGraph(): |
71 graphOrig = showconfig.getGraph() | 58 graphOrig = showconfig.getGraph() |
72 graph = Graph() # a copy, since we're going to add subs into it | 59 graph = Graph() # a copy, since we're going to add subs into it |
73 for s in graphOrig: | 60 for s in graphOrig: |
128 line = tk.Label(root, text=helpline, font="Helvetica -12 italic", | 115 line = tk.Label(root, text=helpline, font="Helvetica -12 italic", |
129 anchor='w') | 116 anchor='w') |
130 line.pack(side='top',fill='x') | 117 line.pack(side='top',fill='x') |
131 | 118 |
132 class Main(object): | 119 class Main(object): |
133 def __init__(self): | 120 def __init__(self, graph, song, curveset, subterms): |
121 self.graph = graph | |
134 wtree = gtk.Builder() | 122 wtree = gtk.Builder() |
135 wtree.add_from_file(sibpath(__file__, "../light9/curvecalc/curvecalc.glade")) | 123 wtree.add_from_file(sibpath(__file__, "../light9/curvecalc/curvecalc.glade")) |
136 mainwin = wtree.get_object("MainWindow") | 124 mainwin = wtree.get_object("MainWindow") |
137 mainwin.connect("destroy", gtk.main_quit) | 125 mainwin.connect("destroy", gtk.main_quit) |
138 wtree.connect_signals(self) | 126 wtree.connect_signals(self) |
139 mainwin.show_all() | 127 mainwin.show_all() |
140 #gobject.timeout_add(1000 // framerate, self.updateLoop) | 128 #gobject.timeout_add(1000 // framerate, self.updateLoop) |
129 | |
130 mainwin.set_title("curvecalc - %s" % graph.label(song)) | |
131 | |
132 self.add_subterms_for_song(song, curveset, subterms, | |
133 wtree.get_object("subterms") | |
134 ) | |
135 | |
136 def add_subterms_for_song(self, song, curveset, subterms, master): | |
137 for st in self.graph.objects(song, L9['subterm']): | |
138 log.info("song %s has subterm %s", song, st) | |
139 add_one_subterm(self.graph, | |
140 self.graph.value(st, L9['sub']), | |
141 curveset, | |
142 subterms, | |
143 master, | |
144 self.graph.value(st, L9['expression'])) | |
145 master.show_all() | |
141 | 146 |
142 def main(): | 147 def main(): |
143 startTime = time.time() | 148 startTime = time.time() |
144 parser = optparse.OptionParser() | 149 parser = optparse.OptionParser() |
145 parser.set_usage("%prog [opts] [songURI]") | 150 parser.set_usage("%prog [opts] [songURI]") |
163 song = currentlyPlayingSong() | 168 song = currentlyPlayingSong() |
164 | 169 |
165 music=Music() | 170 music=Music() |
166 graph = makeGraph() | 171 graph = makeGraph() |
167 | 172 |
168 start=Main() | |
169 #gtk2reactor.install() | |
170 | |
171 if opts.startup_only: | |
172 log.debug("quitting now because of --startup-only") | |
173 return | |
174 | |
175 gtk.main() | |
176 1/0 | |
177 ################### | |
178 | |
179 curveset = Curveset(sliders=opts.sliders) | 173 curveset = Curveset(sliders=opts.sliders) |
180 subterms = [] | 174 subterms = [] |
181 | 175 |
182 subtermPath = graphPathForSubterms(song) | 176 subtermPath = graphPathForSubterms(song) |
183 try: | 177 try: |
192 | 186 |
193 musicfilename = showconfig.songOnDisk(song) | 187 musicfilename = showconfig.songOnDisk(song) |
194 maxtime = wavelength(musicfilename) | 188 maxtime = wavelength(musicfilename) |
195 dispatcher.connect(lambda: maxtime, "get max time", weak=False) | 189 dispatcher.connect(lambda: maxtime, "get max time", weak=False) |
196 | 190 |
197 root.title("curvecalc - %s" % graph.label(song)) | 191 start = Main(graph, song, curveset, subterms) |
192 #gtk2reactor.install() | |
193 | |
194 if opts.startup_only: | |
195 log.debug("quitting now because of --startup-only") | |
196 return | |
197 | |
198 gtk.main() | |
199 1/0 | |
200 ################### | |
201 | |
198 | 202 |
199 if 'fixed top rows': | 203 if 'fixed top rows': |
200 zc = Zoomcontrol(root) | 204 zc = Zoomcontrol(root) |
201 zc.pack(side='top', fill='x') | 205 zc.pack(side='top', fill='x') |
202 | 206 |
223 | 227 |
224 helpBox = tk.Frame(root) | 228 helpBox = tk.Frame(root) |
225 createHelpLines(helpBox) | 229 createHelpLines(helpBox) |
226 helpBox.pack(side='top', fill='x') | 230 helpBox.pack(side='top', fill='x') |
227 | 231 |
228 add_subterms_for_song(graph, song, curveset, subterms, | |
229 subtermScroll.subwidget('window')) | |
230 setupKeyBindings(root, song, subterms, curveset) | 232 setupKeyBindings(root, song, subterms, curveset) |
231 setupMenubar(menubar, root, song, subterms, curveset) | 233 setupMenubar(menubar, root, song, subterms, curveset) |
232 | 234 |
233 # curvesetview must already exist, since this makes 'add_curve' | 235 # curvesetview must already exist, since this makes 'add_curve' |
234 # signals for all the initial curves | 236 # signals for all the initial curves |