Mercurial > code > home > repos > light9
diff light8/uihelpers.py @ 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 | e9d2e7754fd9 |
children | 2ae11dc56b38 |
line wrap: on
line diff
--- 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):