# HG changeset patch # User dmcc # Date 2002-07-08 03:25:42 # Node ID 065896b0913c2d3d312f7f07fa2c521b0cecb20a # Parent 71489bb7152875fdfd6ee9bf75d3fa85c1046c97 emergency commit diff --git a/Widgets/FlyingFader.py b/Widgets/FlyingFader.py --- a/Widgets/FlyingFader.py +++ b/Widgets/FlyingFader.py @@ -1,4 +1,4 @@ -from Tkinter import * +from Tix import * from time import time,sleep from __future__ import division @@ -152,7 +152,8 @@ class FlyingFader(Frame): self.after(30, self.gofade) def updatelabel(self, *args): - self.vlabel['text'] = "%.3f" % self.variable.get() + if self.variable: + self.vlabel['text'] = "%.3f" % self.variable.get() # if self.fadetimes[1] == 0: # no fade # self.vlabel['fg'] = 'black' # elif self.curfade[1] > self.curfade[0]: @@ -166,7 +167,6 @@ class FlyingFader(Frame): def set(self, val): self.scale.set(val) - def colorfade(scale, lev): low = (255, 255, 255) high = (0, 0, 0) diff --git a/light8/ConfigDummy.py b/light8/ConfigDummy.py --- a/light8/ConfigDummy.py +++ b/light8/ConfigDummy.py @@ -8,7 +8,7 @@ f1 = Fade('red', 0, 2, 100) f2 = Fade('green', 1, 3, 50) f3 = Fade('blue', 0, 4, 0) f4 = Fade('clear', 0, 8, 75) -c1 = Cue("Color shift", 0, 10, f1, f2, f3, f4) +c1 = Cue("Color shift", 0, 10, None, f1, f2, f3, f4) cues = [c1] diff --git a/light8/Fader.py b/light8/Fader.py --- a/light8/Fader.py +++ b/light8/Fader.py @@ -1,4 +1,12 @@ from Tix import * +from time import time # time is on my side +from util import subsetdict + +# statuses are: +# stopped - no cue is loaded +# running - cue is running, not complete +# halted - cue stops wherever it was, can't continue +# finished - cue is finished, next is loaded stdfont = ('Arial', 10) @@ -12,9 +20,19 @@ class Fader(Frame): def init_layout(self): Frame.__init__(self, self.master) + # info variables self.cuename = StringVar() self.cuelength = DoubleVar() - self.cueend = StringVar() + self.cuetarget = StringVar() + + # info about a running cue + self.cuestatus = StringVar() # text description + self.cuestatus.set("stopped") + + self.cuepercent = DoubleVar() # percent complete + self.cuepercent.set(0) + self.cuetime = StringVar() # time left + self.cuetime.set('0 / 0') buttonframe = Frame(self) @@ -30,25 +48,54 @@ class Fader(Frame): infoframe = Frame(self) Label(infoframe, textvariable=self.cuename, font=('Arial', 12), bg='lightBlue').grid(columnspan=2, sticky=NE+SW) + Label(infoframe, text="Length", font=stdfont, bg='lightPink').grid(row=1, sticky=NE+SW) Label(infoframe, textvariable=self.cuelength, font=stdfont).grid(row=1, column=1, sticky=NE+SW) + Label(infoframe, text="Target", font=stdfont, - bg='lightPink').grid(row=2, sticky=NE+SW) - Label(infoframe, textvariable=self.cueend, + bg='lightPink', wraplength=50).grid(row=2, sticky=NE+SW) + Label(infoframe, textvariable=self.cuetarget, font=stdfont).grid(row=2, column=1, sticky=NE+SW) + + Label(infoframe, text="Status", font=stdfont, + bg='lightPink').grid(row=3, sticky=NE+SW) + Label(infoframe, textvariable=self.cuestatus, + font=stdfont).grid(row=3, column=1, sticky=NE+SW) + + Label(infoframe, text="Time", font=stdfont, + bg='lightPink').grid(row=4, sticky=NE+SW) + Label(infoframe, textvariable=self.cuetime, + font=stdfont).grid(row=4, column=1, sticky=NE+SW) + + Label(infoframe, text="Percent Complete", font=stdfont, + bg='lightPink').grid(row=5, sticky=NE+SW) + Label(infoframe, textvariable=self.cuepercent, + font=stdfont).grid(row=5, column=1, sticky=NE+SW) + infoframe.pack(side=RIGHT, fill=BOTH, expand=1) buttonframe.pack(side=BOTTOM) self.listbox.listbox.select_set(0) self.update_selection() def update_selection(self): - print self.listbox.listbox.curselection() selection = int(self.listbox.listbox.curselection()[0]) # blech self.current = self.cues[selection] self.cuename.set(self.current.name) self.cuelength.set(self.current.dur) - self.cueend.set(str(self.current.get_end_levels())) + self.cuetarget.set(str(self.current.get_end_levels())) def go(self): print 'Fade to', self.current.name + self.cuestatus.set("running") + self.time_start = time() + startlevels = dict([(k, v.get()) for k, v in self.scalelevels.items()]) + self.current.start(startlevels, self.time_start) + self.running_loop() + def running_loop(self): + curtime = time() + if (curtime - self.time_start) > self.current.dur: + return + newlevels = self.current.get_levels(time()) + print newlevels + self.after(30, self.running_loop) diff --git a/light8/panels.py b/light8/panels.py --- a/light8/panels.py +++ b/light8/panels.py @@ -157,8 +157,9 @@ class Subpanels: for axis in ('y','x'): cvar=IntVar() - cb=Togglebutton(f,text=axis.upper(),variable=cvar,font=stdfont, padx=0, - pady=0, bd=1) + eb_color = ('red', 'green')[axis == 'y'] + cb=Togglebutton(f,text=axis.upper(),variable=cvar,font=stdfont, + padx=0, pady=0, bd=1, downcolor=eb_color) cb.pack(side=side1,fill='both', padx=0, pady=0) s.bind(''%axis, lambda ev,cb=cb: cb.invoke) xfader.registerbutton(name,axis,cvar) diff --git a/light8/uihelpers.py b/light8/uihelpers.py --- a/light8/uihelpers.py +++ b/light8/uihelpers.py @@ -60,12 +60,13 @@ class Togglebutton(Button): label's on the button face, not to the side. the optional command callback is called on button set, not on unset. takes a variable just like a checkbutton""" - def __init__(self,parent,variable=None,command=None,**kw): + def __init__(self,parent,variable=None,command=None,downcolor='red',**kw): self.oldcommand = command Button.__init__(self,parent,command=self.invoke,**kw) self._origbkg = self.cget('bg') + self.downcolor = downcolor self._variable = variable if self._variable: @@ -94,7 +95,7 @@ class Togglebutton(Button): def _setstate(self,newstate): self.state = newstate if newstate: # set - self.config(bg='red',relief='sunken') + self.config(bg=self.downcolor,relief='sunken') else: # unset self.config(bg=self._origbkg,relief='raised') return "break"