diff --git a/light8/panels.py b/light8/panels.py --- a/light8/panels.py +++ b/light8/panels.py @@ -47,7 +47,7 @@ class Leveldisplay: 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 @@ class Leveldisplay: 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, diff --git a/light8/rsn.py b/light8/rsn.py --- a/light8/rsn.py +++ b/light8/rsn.py @@ -4,7 +4,7 @@ from __future__ import nested_scopes 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 @@ class Lightboard: leveldisplay_tl = toplevelat(873,400) leveldisplay_tl.bind('', sys.exit) - leveldisplay = Leveldisplay(leveldisplay_tl, self.channel_levels) + self.leveldisplay = Leveldisplay(leveldisplay_tl, self.channel_levels) Console() @@ -105,10 +105,18 @@ class Lightboard: 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[:] diff --git a/light8/uihelpers.py b/light8/uihelpers.py --- a/light8/uihelpers.py +++ b/light8/uihelpers.py @@ -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 @@ def colorlabel(label): 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):