Mercurial > code > home > repos > light9
annotate bin/curvecalc @ 690:847edbfe65c8
refactor subterms
Ignore-this: 632a7fcc1917ceed60970e69e85d03f5
author | drewp@bigasterisk.com |
---|---|
date | Wed, 06 Jun 2012 01:31:51 +0000 |
parents | 03453848ed4c |
children | 62d83d456f2e |
rev | line source |
---|---|
686
a301a0039c66
buildout and rdflib updates
Drew Perttula <drewp@bigasterisk.com>
parents:
684
diff
changeset
|
1 #!bin/python |
0 | 2 |
197
ba2677823b35
zoom control and other cleanups. also reads song length now
drewp
parents:
196
diff
changeset
|
3 """ |
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:
335
diff
changeset
|
4 now launches like this: |
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:
335
diff
changeset
|
5 % bin/curvecalc http://light9.bigasterisk.com/show/dance2007/song1 |
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:
335
diff
changeset
|
6 |
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:
335
diff
changeset
|
7 |
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:
335
diff
changeset
|
8 |
197
ba2677823b35
zoom control and other cleanups. also reads song length now
drewp
parents:
196
diff
changeset
|
9 todo: curveview should preserve more objects, for speed maybe |
ba2677823b35
zoom control and other cleanups. also reads song length now
drewp
parents:
196
diff
changeset
|
10 |
ba2677823b35
zoom control and other cleanups. also reads song length now
drewp
parents:
196
diff
changeset
|
11 """ |
0 | 12 from __future__ import division |
690 | 13 import time,textwrap,os,optparse, urllib2 |
505 | 14 import Tix as tk |
689 | 15 import louie as dispatcher |
0 | 16 from twisted.internet import reactor,tksupport |
689 | 17 |
690 | 18 from rdflib import URIRef |
686
a301a0039c66
buildout and rdflib updates
Drew Perttula <drewp@bigasterisk.com>
parents:
684
diff
changeset
|
19 from rdflib import Graph |
400
b2858c2d4a4d
aft() has smooth arg; workaround for CC writing poor subterms
Drew Perttula <drewp@bigasterisk.com>
parents:
399
diff
changeset
|
20 import rdflib |
319
2193eab0650b
add startup logging to curvecalc
Drew Perttula <drewp@bigasterisk.com>
parents:
296
diff
changeset
|
21 import logging |
2193eab0650b
add startup logging to curvecalc
Drew Perttula <drewp@bigasterisk.com>
parents:
296
diff
changeset
|
22 log = logging.getLogger() |
0 | 23 |
210
f41004d5a507
factored out some networking, new show/ layout, curvecalc works
drewp@bigasterisk.com
parents:
205
diff
changeset
|
24 import run_local |
690 | 25 from light9 import showconfig, prof |
688 | 26 from light9.curvecalc.zoomcontrol import Zoomcontrol |
27 from light9.curvecalc.curve import Curveset | |
28 from light9.curvecalc.curveview import Curvesetview | |
689 | 29 from light9.curvecalc.musicaccess import Music, currentlyPlayingSong |
264
0f112a7dd6b3
fix window positoins for subcomposer and curvecalc. now saves geometry continuously
drewp@bigasterisk.com
parents:
248
diff
changeset
|
30 from light9.wavelength import wavelength |
0f112a7dd6b3
fix window positoins for subcomposer and curvecalc. now saves geometry continuously
drewp@bigasterisk.com
parents:
248
diff
changeset
|
31 from light9.uihelpers import toplevelat |
335 | 32 from light9.namespaces import L9 |
690 | 33 from light9.curvecalc.subterm import read_all_subs, savekey, graphPathForSubterms |
34 from light9.curvecalc.subtermview import makeSubtermCommandRow, add_one_subterm | |
35 from light9.curvecalc.output import Output | |
0 | 36 |
516
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
37 def makeStatusLines(master): |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
38 """various labels that listen for dispatcher signals""" |
197
ba2677823b35
zoom control and other cleanups. also reads song length now
drewp
parents:
196
diff
changeset
|
39 for signame,textfilter in [ |
ba2677823b35
zoom control and other cleanups. also reads song length now
drewp
parents:
196
diff
changeset
|
40 ('input time',lambda t: "%.2fs"%t), |
ba2677823b35
zoom control and other cleanups. also reads song length now
drewp
parents:
196
diff
changeset
|
41 ('output levels', |
ba2677823b35
zoom control and other cleanups. also reads song length now
drewp
parents:
196
diff
changeset
|
42 lambda levels: textwrap.fill("; ".join(["%s:%.2f"%(n,v) |
ba2677823b35
zoom control and other cleanups. also reads song length now
drewp
parents:
196
diff
changeset
|
43 for n,v in |
205
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
202
diff
changeset
|
44 levels.items()[:5] |
3905d3c92aaa
twisted mainloop, more row-change keys, xmlrpc fadesub command on port 8050
drewp
parents:
202
diff
changeset
|
45 if v>0]),70)), |
197
ba2677823b35
zoom control and other cleanups. also reads song length now
drewp
parents:
196
diff
changeset
|
46 ('update period',lambda t: "%.1fms"%(t*1000)), |
236
63601fe0c3b0
curvecalc cmdline checking, connection status now in gui
drewp@bigasterisk.com
parents:
230
diff
changeset
|
47 ('update status',lambda t: str(t)), |
197
ba2677823b35
zoom control and other cleanups. also reads song length now
drewp
parents:
196
diff
changeset
|
48 ]: |
516
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
49 l = tk.Label(master, anchor='w', justify='left', text='%s:' % signame) |
197
ba2677823b35
zoom control and other cleanups. also reads song length now
drewp
parents:
196
diff
changeset
|
50 l.pack(side='top',fill='x') |
ba2677823b35
zoom control and other cleanups. also reads song length now
drewp
parents:
196
diff
changeset
|
51 dispatcher.connect(lambda val,l=l,sn=signame,tf=textfilter: |
ba2677823b35
zoom control and other cleanups. also reads song length now
drewp
parents:
196
diff
changeset
|
52 l.config(text=sn+": "+tf(val)), |
516
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
53 signame, weak=False) |
197
ba2677823b35
zoom control and other cleanups. also reads song length now
drewp
parents:
196
diff
changeset
|
54 |
516
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
55 def add_subterms_for_song(graph, song, curveset, subterms, master): |
335 | 56 for st in graph.objects(song, L9['subterm']): |
590 | 57 log.info("song %s has subterm %s", song, st) |
400
b2858c2d4a4d
aft() has smooth arg; workaround for CC writing poor subterms
Drew Perttula <drewp@bigasterisk.com>
parents:
399
diff
changeset
|
58 try: |
516
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
59 add_one_subterm(graph, graph.value(st, L9['sub']), curveset, |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
60 subterms, master, graph.value(st, L9['expression'])) |
400
b2858c2d4a4d
aft() has smooth arg; workaround for CC writing poor subterms
Drew Perttula <drewp@bigasterisk.com>
parents:
399
diff
changeset
|
61 except rdflib.exceptions.UniquenessError: |
b2858c2d4a4d
aft() has smooth arg; workaround for CC writing poor subterms
Drew Perttula <drewp@bigasterisk.com>
parents:
399
diff
changeset
|
62 print "working around curvecalc save corruption" |
b2858c2d4a4d
aft() has smooth arg; workaround for CC writing poor subterms
Drew Perttula <drewp@bigasterisk.com>
parents:
399
diff
changeset
|
63 # curvecalc put all the expressions on one subterm, which is wrong |
b2858c2d4a4d
aft() has smooth arg; workaround for CC writing poor subterms
Drew Perttula <drewp@bigasterisk.com>
parents:
399
diff
changeset
|
64 for expr in graph.objects(st, L9['expression']): |
b2858c2d4a4d
aft() has smooth arg; workaround for CC writing poor subterms
Drew Perttula <drewp@bigasterisk.com>
parents:
399
diff
changeset
|
65 add_one_subterm(graph, graph.value(st, L9['sub']), |
516
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
66 curveset, subterms, master, expr) |
400
b2858c2d4a4d
aft() has smooth arg; workaround for CC writing poor subterms
Drew Perttula <drewp@bigasterisk.com>
parents:
399
diff
changeset
|
67 |
287
5322639d61e9
refactoring and little fixes in curvecalc and keyboardcomposer
Drew Perttula <drewp@bigasterisk.com>
parents:
284
diff
changeset
|
68 |
505 | 69 def makeGraph(): |
70 graphOrig = showconfig.getGraph() | |
71 graph = Graph() # a copy, since we're going to add subs into it | |
72 for s in graphOrig: | |
73 graph.add(s) | |
74 read_all_subs(graph) | |
75 return graph | |
0 | 76 |
505 | 77 def setupKeyBindings(root, song, subterms, curveset): |
78 root.bind("<Control-Key-s>", | |
79 lambda *args: savekey(song, subterms, curveset)) | |
80 root.bind("<Control-Key-r>", lambda evt: dispatcher.send('reload all subs')) | |
81 root.bind("<Control-Key-n>", | |
82 lambda evt: dispatcher.send('focus new subterm')) | |
83 root.bind("<Control-Key-N>", lambda evt: dispatcher.send('focus new curve')) | |
84 root.bind("<Control-Key-q>",lambda ev: reactor.stop) | |
85 root.bind("<Destroy>",lambda ev: reactor.stop) | |
86 root.protocol('WM_DELETE_WINDOW', reactor.stop) | |
87 | |
641
c113c759559b
more menubar. not many working actions yet
Drew Perttula <drewp@bigasterisk.com>
parents:
639
diff
changeset
|
88 def setupMenubar(barFrame, root, song, subterms, curveset): |
639 | 89 class newMenu(object): |
90 def __init__(self, name): | |
91 self.name = name | |
92 def __enter__(self): | |
93 m = tk.Menubutton(barFrame, text=self.name) | |
94 m.pack(side='left') | |
95 mm = tk.Menu(m) | |
96 m.config(menu=mm) | |
97 return mm | |
98 def __exit__(self, type, value, traceback): | |
99 return False | |
100 | |
641
c113c759559b
more menubar. not many working actions yet
Drew Perttula <drewp@bigasterisk.com>
parents:
639
diff
changeset
|
101 def notImpl(*args): |
c113c759559b
more menubar. not many working actions yet
Drew Perttula <drewp@bigasterisk.com>
parents:
639
diff
changeset
|
102 print "sorry, menu command binding isn't done yet. Use the keyboard shortcut" |
c113c759559b
more menubar. not many working actions yet
Drew Perttula <drewp@bigasterisk.com>
parents:
639
diff
changeset
|
103 |
c113c759559b
more menubar. not many working actions yet
Drew Perttula <drewp@bigasterisk.com>
parents:
639
diff
changeset
|
104 with newMenu("Curvecalc") as m: |
c113c759559b
more menubar. not many working actions yet
Drew Perttula <drewp@bigasterisk.com>
parents:
639
diff
changeset
|
105 m.add_command(label='Save', underline=0, accelerator="Ctrl+s", |
c113c759559b
more menubar. not many working actions yet
Drew Perttula <drewp@bigasterisk.com>
parents:
639
diff
changeset
|
106 command=lambda *args: savekey(song, subterms, curveset)) |
c113c759559b
more menubar. not many working actions yet
Drew Perttula <drewp@bigasterisk.com>
parents:
639
diff
changeset
|
107 m.add_command(label='Quit', command=root.destroy) |
c113c759559b
more menubar. not many working actions yet
Drew Perttula <drewp@bigasterisk.com>
parents:
639
diff
changeset
|
108 |
c113c759559b
more menubar. not many working actions yet
Drew Perttula <drewp@bigasterisk.com>
parents:
639
diff
changeset
|
109 with newMenu("View") as m: |
c113c759559b
more menubar. not many working actions yet
Drew Perttula <drewp@bigasterisk.com>
parents:
639
diff
changeset
|
110 m.add_command(label="See current time", accelerator="Esc", command=notImpl) |
c113c759559b
more menubar. not many working actions yet
Drew Perttula <drewp@bigasterisk.com>
parents:
639
diff
changeset
|
111 m.add_command(label="See from current time -> end", accelerator="Shift+Esc", command=notImpl) |
c113c759559b
more menubar. not many working actions yet
Drew Perttula <drewp@bigasterisk.com>
parents:
639
diff
changeset
|
112 m.add_command(label="Zoom all", accelerator="Ctrl+Esc", command=notImpl) |
c113c759559b
more menubar. not many working actions yet
Drew Perttula <drewp@bigasterisk.com>
parents:
639
diff
changeset
|
113 m.add_command(label="Zoom in", accelerator="Wheel up", command=notImpl) |
c113c759559b
more menubar. not many working actions yet
Drew Perttula <drewp@bigasterisk.com>
parents:
639
diff
changeset
|
114 m.add_command(label="Zoom out", accelerator="Wheel down", command=notImpl) |
c113c759559b
more menubar. not many working actions yet
Drew Perttula <drewp@bigasterisk.com>
parents:
639
diff
changeset
|
115 |
c113c759559b
more menubar. not many working actions yet
Drew Perttula <drewp@bigasterisk.com>
parents:
639
diff
changeset
|
116 with newMenu("Playback") as m: |
c113c759559b
more menubar. not many working actions yet
Drew Perttula <drewp@bigasterisk.com>
parents:
639
diff
changeset
|
117 m.add_command(label="Play/pause at mouse", accelerator="Ctrl+P", command=notImpl) |
c113c759559b
more menubar. not many working actions yet
Drew Perttula <drewp@bigasterisk.com>
parents:
639
diff
changeset
|
118 |
c113c759559b
more menubar. not many working actions yet
Drew Perttula <drewp@bigasterisk.com>
parents:
639
diff
changeset
|
119 with newMenu("Points") as m: |
c113c759559b
more menubar. not many working actions yet
Drew Perttula <drewp@bigasterisk.com>
parents:
639
diff
changeset
|
120 m.add_command(label="Delete", accelerator="Del", command=notImpl) |
c113c759559b
more menubar. not many working actions yet
Drew Perttula <drewp@bigasterisk.com>
parents:
639
diff
changeset
|
121 |
639 | 122 |
505 | 123 def createHelpLines(root): |
641
c113c759559b
more menubar. not many working actions yet
Drew Perttula <drewp@bigasterisk.com>
parents:
639
diff
changeset
|
124 for helpline in ["Mousewheel zoom; C-p play/pause music at mouse", |
c113c759559b
more menubar. not many working actions yet
Drew Perttula <drewp@bigasterisk.com>
parents:
639
diff
changeset
|
125 "Curve point bindings: B1 drag point; C-B1 curve add point; S-B1 sketch points; 1..5 add point at time; B1 drag select points", |
505 | 126 "Available in functions: nsin/ncos period=amp=1; within(a,b) bef(x) aft(x) compare to time; smoove(x) cubic smoothstep; chan(name); curvename(t) eval curve"]: |
127 line = tk.Label(root, text=helpline, font="Helvetica -12 italic", | |
128 anchor='w') | |
129 line.pack(side='top',fill='x') | |
130 | |
131 def main(): | |
680
ad17b0a09f5c
CC more startup logging, timing option to quit after init
drewp@bigasterisk.com
parents:
641
diff
changeset
|
132 startTime = time.time() |
505 | 133 parser = optparse.OptionParser() |
551
ad5043f70fda
bin/curvecalc (with no song choice) defaults to whatever-ascoltami-is-currently-on
drewp@bigasterisk.com
parents:
532
diff
changeset
|
134 parser.set_usage("%prog [opts] [songURI]") |
505 | 135 parser.add_option("--sliders", action='store_true', |
136 help='use hardware sliders') | |
137 parser.add_option("--skip-music", action='store_true', | |
138 help="ignore music and smooth_music curve files") | |
680
ad17b0a09f5c
CC more startup logging, timing option to quit after init
drewp@bigasterisk.com
parents:
641
diff
changeset
|
139 parser.add_option("--debug", action="store_true", |
ad17b0a09f5c
CC more startup logging, timing option to quit after init
drewp@bigasterisk.com
parents:
641
diff
changeset
|
140 help="log at DEBUG") |
ad17b0a09f5c
CC more startup logging, timing option to quit after init
drewp@bigasterisk.com
parents:
641
diff
changeset
|
141 parser.add_option("--startup-only", action='store_true', |
ad17b0a09f5c
CC more startup logging, timing option to quit after init
drewp@bigasterisk.com
parents:
641
diff
changeset
|
142 help="quit after loading everything (for timing tests)") |
505 | 143 opts, args = parser.parse_args() |
144 | |
590 | 145 logging.basicConfig(format="%(asctime)s %(levelname)-5s %(name)s %(filename)s:%(lineno)d: %(message)s") |
680
ad17b0a09f5c
CC more startup logging, timing option to quit after init
drewp@bigasterisk.com
parents:
641
diff
changeset
|
146 log.setLevel(logging.DEBUG if opts.debug else logging.INFO) |
590 | 147 |
680
ad17b0a09f5c
CC more startup logging, timing option to quit after init
drewp@bigasterisk.com
parents:
641
diff
changeset
|
148 log.debug("startup: music %s", time.time() - startTime) |
505 | 149 try: |
150 song = URIRef(args[0]) | |
151 except IndexError: | |
551
ad5043f70fda
bin/curvecalc (with no song choice) defaults to whatever-ascoltami-is-currently-on
drewp@bigasterisk.com
parents:
532
diff
changeset
|
152 song = currentlyPlayingSong() |
505 | 153 |
154 music=Music() | |
516
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
155 graph = makeGraph() |
505 | 156 curveset = Curveset(sliders=opts.sliders) |
516
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
157 subterms = [] |
505 | 158 |
637
af5539fe35a7
CC startup doesn't need a subterms file. it'll make the first one
Drew Perttula <drewp@bigasterisk.com>
parents:
636
diff
changeset
|
159 subtermPath = graphPathForSubterms(song) |
af5539fe35a7
CC startup doesn't need a subterms file. it'll make the first one
Drew Perttula <drewp@bigasterisk.com>
parents:
636
diff
changeset
|
160 try: |
af5539fe35a7
CC startup doesn't need a subterms file. it'll make the first one
Drew Perttula <drewp@bigasterisk.com>
parents:
636
diff
changeset
|
161 graph.parse(subtermPath, format='n3') |
af5539fe35a7
CC startup doesn't need a subterms file. it'll make the first one
Drew Perttula <drewp@bigasterisk.com>
parents:
636
diff
changeset
|
162 except urllib2.URLError, e: |
af5539fe35a7
CC startup doesn't need a subterms file. it'll make the first one
Drew Perttula <drewp@bigasterisk.com>
parents:
636
diff
changeset
|
163 if e.reason.errno != 2: |
af5539fe35a7
CC startup doesn't need a subterms file. it'll make the first one
Drew Perttula <drewp@bigasterisk.com>
parents:
636
diff
changeset
|
164 raise |
af5539fe35a7
CC startup doesn't need a subterms file. it'll make the first one
Drew Perttula <drewp@bigasterisk.com>
parents:
636
diff
changeset
|
165 log.info("%s not found, starting with empty graph" % subtermPath) |
516
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
166 |
680
ad17b0a09f5c
CC more startup logging, timing option to quit after init
drewp@bigasterisk.com
parents:
641
diff
changeset
|
167 log.debug("startup: output %s", time.time() - startTime) |
516
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
168 out = Output(subterms, music) |
505 | 169 |
170 musicfilename = showconfig.songOnDisk(song) | |
171 maxtime = wavelength(musicfilename) | |
516
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
172 dispatcher.connect(lambda: maxtime, "get max time", weak=False) |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
173 |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
174 |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
175 root=tk.Tk() |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
176 root.tk_setPalette("gray50") |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
177 toplevelat("curvecalc",root) |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
178 root.tk_focusFollowsMouse() |
639 | 179 root.title("curvecalc - %s" % graph.label(song)) |
180 | |
181 menubar = tk.Frame(root) | |
182 menubar.pack(side='top', fill='x') | |
516
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
183 |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
184 if 'fixed top rows': |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
185 zc = Zoomcontrol(root) |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
186 zc.pack(side='top', fill='x') |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
187 |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
188 if 'panes': |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
189 panes = tk.PanedWindow(root, height=1) |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
190 panes.add('curvesetView') |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
191 panes.add('subterms') |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
192 panes.pack(side='top', fill='both', expand=True) |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
193 |
519
f2dbb0b1fb35
optimize the number of curve redraws at curvecalc's startup
drewp@bigasterisk.com
parents:
517
diff
changeset
|
194 curvesetView = Curvesetview(panes.subwidget('curvesetView'), curveset, |
613 | 195 height=600) |
519
f2dbb0b1fb35
optimize the number of curve redraws at curvecalc's startup
drewp@bigasterisk.com
parents:
517
diff
changeset
|
196 curvesetView.pack(fill='both', expand=True) |
516
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
197 |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
198 subtermArea = tk.Frame(panes.subwidget('subterms'), height=100) |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
199 subtermArea.pack(fill='both', expand=True) |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
200 |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
201 subtermScroll = tk.ScrolledWindow(subtermArea) |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
202 subtermScroll.pack(fill='both') |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
203 |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
204 if 'fixed bottom rows': |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
205 makeSubtermCommandRow(root, curveset, subterms, root, subtermArea, |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
206 graph).pack(side='top', fill='x') |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
207 makeStatusLines(root) |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
208 |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
209 helpBox = tk.Frame(root) |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
210 createHelpLines(helpBox) |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
211 helpBox.pack(side='top', fill='x') |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
212 |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
213 add_subterms_for_song(graph, song, curveset, subterms, |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
214 subtermScroll.subwidget('window')) |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
215 setupKeyBindings(root, song, subterms, curveset) |
641
c113c759559b
more menubar. not many working actions yet
Drew Perttula <drewp@bigasterisk.com>
parents:
639
diff
changeset
|
216 setupMenubar(menubar, root, song, subterms, curveset) |
516
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
217 |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
218 # curvesetview must already exist, since this makes 'add_curve' |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
219 # signals for all the initial curves |
505 | 220 curveset.load(basename=os.path.join(showconfig.curvesDir(), |
221 showconfig.songFilenameFromURI(song)), | |
222 skipMusic=opts.skip_music) | |
516
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
223 |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
224 dispatcher.send("max time",maxtime=maxtime) |
73b181155555
curvecalc ui touchups, adjustable pane, curve draw speedup, restructured main layout code
drewp@bigasterisk.com
parents:
505
diff
changeset
|
225 dispatcher.send("show all") |
519
f2dbb0b1fb35
optimize the number of curve redraws at curvecalc's startup
drewp@bigasterisk.com
parents:
517
diff
changeset
|
226 |
f2dbb0b1fb35
optimize the number of curve redraws at curvecalc's startup
drewp@bigasterisk.com
parents:
517
diff
changeset
|
227 # this is scheduled after some tk shuffling, to try to minimize |
f2dbb0b1fb35
optimize the number of curve redraws at curvecalc's startup
drewp@bigasterisk.com
parents:
517
diff
changeset
|
228 # the number of times we redraw the curve at startup. If tk is |
f2dbb0b1fb35
optimize the number of curve redraws at curvecalc's startup
drewp@bigasterisk.com
parents:
517
diff
changeset
|
229 # very slow, it's ok. You'll just get some wasted redraws. |
f2dbb0b1fb35
optimize the number of curve redraws at curvecalc's startup
drewp@bigasterisk.com
parents:
517
diff
changeset
|
230 reactor.callLater(.1, curvesetView.goLive) |
505 | 231 |
517
f15ffbfc5cd6
speed up curvecalc tk update to 10ms (since we recently sped up the recalcs)
drewp@bigasterisk.com
parents:
516
diff
changeset
|
232 tksupport.install(root, ms=10) |
680
ad17b0a09f5c
CC more startup logging, timing option to quit after init
drewp@bigasterisk.com
parents:
641
diff
changeset
|
233 log.debug("startup: run %s", time.time() - startTime) |
ad17b0a09f5c
CC more startup logging, timing option to quit after init
drewp@bigasterisk.com
parents:
641
diff
changeset
|
234 if opts.startup_only: |
ad17b0a09f5c
CC more startup logging, timing option to quit after init
drewp@bigasterisk.com
parents:
641
diff
changeset
|
235 log.debug("quitting now because of --startup-only") |
ad17b0a09f5c
CC more startup logging, timing option to quit after init
drewp@bigasterisk.com
parents:
641
diff
changeset
|
236 return |
505 | 237 prof.run(reactor.run, profile=False) |
238 | |
239 main() |