comparison 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
comparison
equal deleted inserted replaced
33:d9a0f6c88b39 34:411de8b46aef
1 """all the tiny tk helper functions""" 1 """all the tiny tk helper functions"""
2 2
3 from Tkinter import * 3 from Tkinter import *
4 from types import StringType
4 5
5 def make_frame(parent): 6 def make_frame(parent):
6 f = Frame(parent, bd=0) 7 f = Frame(parent, bd=0)
7 f.pack(side='left') 8 f.pack(side='left')
8 return f 9 return f
37 low=(80,80,180) 38 low=(80,80,180)
38 high=(255,55,050) 39 high=(255,55,050)
39 out = [int(l+lev*(h-l)) for h,l in zip(high,low)] 40 out = [int(l+lev*(h-l)) for h,l in zip(high,low)]
40 col="#%02X%02X%02X" % tuple(out) 41 col="#%02X%02X%02X" % tuple(out)
41 label.config(bg=col) 42 label.config(bg=col)
43
44 # TODO: get everyone to use this
45 def colorfade(low, high, percent):
46 '''not foolproof. make sure 0 < percent < 1'''
47 out = [int(l+percent*(h-l)) for h,l in zip(high,low)]
48 col="#%02X%02X%02X" % tuple(out)
49 return col
50
51 def colortotuple(anytkobj, colorname):
52 'pass any tk object and a color name, like "yellow"'
53 rgb = anytkobj.winfo_rgb(colorname)
54 return [v / 256 for v in rgb]
42 55
43 class Togglebutton(Button): 56 class Togglebutton(Button):
44 """works like a single radiobutton, but it's a button so the label's on the button face, not to the side""" 57 """works like a single radiobutton, but it's a button so the label's on the button face, not to the side"""
45 def __init__(self,parent,**kw): 58 def __init__(self,parent,**kw):
46 if kw['variable']: 59 if kw['variable']: