Mercurial > code > home > repos > light9
changeset 34:411de8b46aef
the famous you-are-in-the-process-of-changing-this-light indicator.
the famous you-are-in-the-process-of-changing-this-light indicator.
red = going up
blue = going down
also, a generic color fader in uihelpers.py -- unused (as of now)
author | dmcc |
---|---|
date | Sun, 07 Jul 2002 12:06:16 +0000 |
parents | d9a0f6c88b39 |
children | 3cbe7110d8f7 |
files | light8/panels.py light8/rsn.py light8/uihelpers.py |
diffstat | 3 files changed, 26 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/light8/panels.py Sun Jul 07 10:55:05 2002 +0000 +++ b/light8/panels.py Sun Jul 07 12:06:16 2002 +0000 @@ -47,7 +47,7 @@ def __init__(self, parent, channel_levels, num_channels=68): frames = (make_frame(parent), make_frame(parent)) channel_levels[:]=[] - self.number_labels = {} + self.number_labels = [] for channel in range(1, num_channels+1): # frame for this channel @@ -56,7 +56,7 @@ num_lab = Label(f, text=str(channel), width=3, bg='lightPink', font=stdfont, padx=0, pady=0, bd=0, height=1) num_lab.pack(side='left') - self.number_labels[channel] = num_lab + self.number_labels.append(num_lab) # text description of channel Label(f, text=Patch.get_channel_name(channel), width=8,
--- a/light8/rsn.py Sun Jul 07 10:55:05 2002 +0000 +++ b/light8/rsn.py Sun Jul 07 12:06:16 2002 +0000 @@ -4,7 +4,7 @@ from Tkinter import * from time import sleep from signal import * -import sys, thread, cPickle +import sys, thread, cPickle, math import io from uihelpers import * @@ -69,7 +69,7 @@ leveldisplay_tl = toplevelat(873,400) leveldisplay_tl.bind('<Escape>', sys.exit) - leveldisplay = Leveldisplay(leveldisplay_tl, self.channel_levels) + self.leveldisplay = Leveldisplay(leveldisplay_tl, self.channel_levels) Console() @@ -105,10 +105,18 @@ levels = [int(l) for l in levels] - for lev,lab,oldlev in zip(levels, self.channel_levels, self.oldlevels): + for lev,lab,oldlev,numlab in zip(levels, self.channel_levels, + self.oldlevels, + self.leveldisplay.number_labels): if lev != oldlev: lab.config(text="%d" % lev) colorlabel(lab) + if lev < oldlev: + numlab['bg'] = 'red' + else: + numlab['bg'] = 'blue' + else: + numlab['bg'] = 'lightPink' self.oldlevels = levels[:]
--- a/light8/uihelpers.py Sun Jul 07 10:55:05 2002 +0000 +++ b/light8/uihelpers.py Sun Jul 07 12:06:16 2002 +0000 @@ -1,6 +1,7 @@ """all the tiny tk helper functions""" from Tkinter import * +from types import StringType def make_frame(parent): f = Frame(parent, bd=0) @@ -40,6 +41,18 @@ col="#%02X%02X%02X" % tuple(out) label.config(bg=col) +# TODO: get everyone to use this +def colorfade(low, high, percent): + '''not foolproof. make sure 0 < percent < 1''' + out = [int(l+percent*(h-l)) for h,l in zip(high,low)] + col="#%02X%02X%02X" % tuple(out) + return col + +def colortotuple(anytkobj, colorname): + 'pass any tk object and a color name, like "yellow"' + rgb = anytkobj.winfo_rgb(colorname) + return [v / 256 for v in rgb] + class Togglebutton(Button): """works like a single radiobutton, but it's a button so the label's on the button face, not to the side""" def __init__(self,parent,**kw):