Mercurial > code > home > repos > light9
changeset 111:0c619695d6c6
all in a days work
author | dmcc |
---|---|
date | Wed, 11 Jun 2003 09:36:07 +0000 |
parents | 490843093506 |
children | afbdae5e1359 |
files | Widgets/Fadable.py Widgets/FlyingFader.py flax/KeyboardComposer.py |
diffstat | 3 files changed, 34 insertions(+), 123 deletions(-) [+] |
line wrap: on
line diff
--- a/Widgets/Fadable.py Tue Jun 10 10:31:57 2003 +0000 +++ b/Widgets/Fadable.py Wed Jun 11 09:36:07 2003 +0000 @@ -37,7 +37,7 @@ if key_bindings: for k in range(1, 10): self.bind("<Key-%d>" % k, - lambda evt, k=k: self.fade(k / 10.0)) + lambda evt, k=k: self.fade(k * 10.0)) self.bind("<Key-0>", lambda evt: self.fade(100)) self.bind("<grave>", lambda evt: self.fade(0)) @@ -71,9 +71,8 @@ self.fade_end_level = value self.fade_step_time = step_time - if not self.fading: - self.fading = 1 - self.do_fade() + self.fading = 1 + self.do_fade() def do_fade(self): """Actually performs the fade for Fadable.fade. Shouldn't be called directly."""
--- a/Widgets/FlyingFader.py Tue Jun 10 10:31:57 2003 +0000 +++ b/Widgets/FlyingFader.py Wed Jun 11 09:36:07 2003 +0000 @@ -78,7 +78,7 @@ side1=RIGHT side2=LEFT - self.scale = Scale(self, scaleopts) + self.scale = Scale(self, **scaleopts) self.vlabel = Label(self, text="0.0", width=6, font=font) self.label = Label(self, text=label, font=font, anchor='w',width=labelwidth) #wraplength=40, )
--- a/flax/KeyboardComposer.py Tue Jun 10 10:31:57 2003 +0000 +++ b/flax/KeyboardComposer.py Wed Jun 11 09:36:07 2003 +0000 @@ -1,13 +1,13 @@ from __future__ import nested_scopes -import sys, time +import sys sys.path.append('..') from Widgets.Fadable import Fadable from Tix import * -import math, atexit, pickle -from Submaster import Submasters, sub_maxes -import dmxclient -from uihelpers import toplevelat +import math +from Timeline import LevelFrame + +Submaster = LevelFrame nudge_keys = { 'up' : list('qwertyuiop'), @@ -19,54 +19,27 @@ def __init__(self, master, *args, **kw): self.scale_var = kw.get('variable') or DoubleVar() kw.update({'variable' : self.scale_var, - 'from' : 1, 'to' : 0, 'showvalue' : 0, - 'sliderlength' : 15, 'res' : 0.01, - 'width' : 40, 'troughcolor' : 'black', 'bg' : 'grey40', - 'highlightthickness' : 1, 'bd' : 1, - 'highlightcolor' : 'red', 'highlightbackground' : 'black', - 'activebackground' : 'red'}) + 'from' : 100, 'to' : 0, 'showvalue' : 0, + 'sliderlength' : 10}) Scale.__init__(self, master, *args, **kw) - Fadable.__init__(self, var=self.scale_var, wheel_step=0.05) - self.draw_indicator_colors() - def draw_indicator_colors(self): - if self.scale_var.get() == 0: - self['troughcolor'] = 'black' - else: - self['troughcolor'] = 'blue' + Fadable.__init__(self, var=self.scale_var) class SubmasterTk(Frame): def __init__(self, master, name, current_level): - Frame.__init__(self, master, bd=1, relief='raised', bg='black') + Frame.__init__(self, master) self.slider_var = DoubleVar() self.slider_var.set(current_level) self.scale = SubScale(self, variable=self.slider_var, width=20) - namelabel = Label(self, text=name, font="Arial 8", bg='black', - fg='white') - namelabel.pack(side=TOP) - levellabel = Label(self, textvariable=self.slider_var, font="Arial 8", - bg='black', fg='white') - levellabel.pack(side=TOP) + textlabel = Label(self, text=name) + textlabel.pack(side=TOP) self.scale.pack(side=BOTTOM, expand=1, fill=BOTH) class KeyboardComposer(Frame): - def __init__(self, root, submasters, current_sub_levels=None, dmxdummy=0): - Frame.__init__(self, root, bg='black') + def __init__(self, root, submasters, current_sub_levels=None): + Frame.__init__(self, root) self.submasters = submasters - self.dmxdummy = dmxdummy + self.current_sub_levels = current_sub_levels or {} - self.current_sub_levels = {} - if current_sub_levels: - self.current_sub_levels = current_sub_levels - else: - try: - self.current_sub_levels = \ - pickle.load(file('.keyboardcomposer.savedlevels')) - except IOError: - pass - - self.draw_ui() - self.send_levels_loop() - def draw_ui(self): self.rows = [] # this holds Tk Frames for each row self.slider_vars = {} # this holds subname:sub Tk vars self.slider_table = {} # this holds coords:sub Tk vars @@ -76,19 +49,6 @@ self.draw_sliders() self.highlight_row(self.current_row) self.rows[self.current_row].focus() - - self.buttonframe = Frame(self, bg='black') - self.buttonframe.pack(side=BOTTOM) - self.refreshbutton = Button(self.buttonframe, text="Refresh", - command=self.refresh, bg='black', fg='white') - self.refreshbutton.pack(side=LEFT) - self.save_stage_button = Button(self.buttonframe, text="Save", - command=lambda: self.save_current_stage(self.sub_name.get()), - bg='black', fg='white') - self.save_stage_button.pack(side=LEFT) - self.sub_name = Entry(self.buttonframe, bg='black', fg='white') - self.sub_name.pack(side=LEFT) - self.stop_frequent_update_time = 0 def make_key_hints(self): keyhintrow = Frame(self) @@ -97,11 +57,10 @@ nudge_keys['down']): # what a hack! downkey = downkey.replace('semicolon', ';') - upkey, downkey = (upkey.upper(), downkey.upper()) # another what a hack! keylabel = Label(keyhintrow, text='%s\n%s' % (upkey, downkey), - width=1, font=('Arial', 10), bg='red', fg='white', anchor='c') + width=3, font=('Arial Bold', 12), bg='red', fg='white') keylabel.pack(side=LEFT, expand=1, fill=X) col += 1 @@ -129,7 +88,7 @@ def change_row(self, event): diff = 1 - if event.keysym in ('Prior', 'p'): + if event.keysym in ('Prior', '<Control-p>'): diff = -1 old_row = self.current_row self.current_row += diff @@ -140,10 +99,11 @@ row = self.rows[self.current_row] self.keyhints.pack_configure(before=row) def got_nudger(self, number, direction, full=0): + print "got_nudger", number, direction, full subtk = self.slider_table[(self.current_row, number)] if direction == 'up': if full: - subtk.scale.fade(1) + subtk.scale.fade(100) else: subtk.scale.increase() else: @@ -156,7 +116,7 @@ rowcount = -1 col = 0 - for sub in self.submasters.get_all_subs(): + for sub in self.submasters: if col == 0: # make new row row = self.make_row() rowcount += 1 @@ -165,14 +125,8 @@ self.slider_table[(rowcount, col)] = subtk col += 1 col %= 10 - - def slider_changed(x, y, z, subtk=subtk): - subtk.scale.draw_indicator_colors() - self.send_levels() - - subtk.slider_var.trace('w', slider_changed) def make_row(self): - row = Frame(self, bd=2, bg='black') + row = Frame(self, bd=2) row.pack(expand=1, fill=BOTH) self.setup_key_nudgers(row) self.rows.append(row) @@ -189,63 +143,21 @@ row['bg'] = 'red' def unhighlight_row(self, row): row = self.rows[row] - row['bg'] = 'black' + row['bg'] = '#d9d9d9' def get_levels(self): return dict([(name, slidervar.get()) for name, slidervar in self.slider_vars.items()]) - def get_levels_as_sub(self): - scaledsubs = [self.submasters.get_sub_by_name(sub) * level \ - for sub, level in self.get_levels().items()] - - maxes = sub_maxes(*scaledsubs) - return maxes - def save_current_stage(self, subname): - print "saving current levels as", subname - sub = self.get_levels_as_sub() - sub.name = subname - sub.save() - - def save(self): - pickle.dump(self.get_levels(), - file('.keyboardcomposer.savedlevels', 'w')) - def send_frequent_updates(self): - """called when we get a fade -- send events as quickly as possible""" - if time.time() <= self.stop_frequent_update_time: - self.send_levels() - self.after(10, self.send_frequent_updates) - - def get_dmx_list(self): - maxes = self.get_levels_as_sub() - return maxes.get_dmx_list() - def send_levels(self): - if not self.dmxdummy: - levels = self.get_dmx_list() - dmxclient.outputlevels(levels) - # print "sending levels", levels - def send_levels_loop(self): - self.send_levels() - self.after(1000, self.send_levels_loop) - def refresh(self): - self.save() - self.submasters = Submasters() - self.current_sub_levels = \ - pickle.load(file('.keyboardcomposer.savedlevels')) - for r in self.rows: - r.destroy() - self.keyhints.destroy() - self.buttonframe.destroy() - self.draw_ui() if __name__ == "__main__": - s = Submasters() + reds = Submaster('reds', {'red1' : 20, 'red2' : 30, 'red3' : 80}) + blues = Submaster('blues', {'blue1' : 60, 'blue2' : 80, 'blue3' : 20}) + + subs = [] + for scenename in 'warmers house god spot explosion booth stageleft stageright donkey elvis sun fiddler satan lola bed treehouse motel6 deadmics suck burninggels firelights sodacan lighting homestar strongbad coachz pompom marzipan bubs thecheat'.split(): + subs.append(Submaster(scenename, {'dummy' : 20})) root = Tk() - tl = toplevelat("Keyboard Composer", existingtoplevel=root) - kc = KeyboardComposer(tl, s, dmxdummy=0) + root.wm_geometry('400x400') + kc = KeyboardComposer(root, subs) kc.pack(fill=BOTH, expand=1) - atexit.register(kc.save) - try: - mainloop() - except KeyboardInterrupt: - tl.destroy() - sys.exit() + mainloop()