annotate light8/uihelpers.py @ 12:7adc65771676

big restructuring - moved lots of things (including most panels) to other files
author drewp
date Sun, 07 Jul 2002 06:16:11 +0000
parents 45b12307c695
children 219d6fcbc28d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
1 """all the tiny tk helper functions"""
45b12307c695 Initial revision
drewp
parents:
diff changeset
2
45b12307c695 Initial revision
drewp
parents:
diff changeset
3 from Tkinter import *
45b12307c695 Initial revision
drewp
parents:
diff changeset
4
45b12307c695 Initial revision
drewp
parents:
diff changeset
5 def make_frame(parent):
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 0
diff changeset
6 f = Frame(parent, bd=0)
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
7 f.pack(side='left')
45b12307c695 Initial revision
drewp
parents:
diff changeset
8 return f
45b12307c695 Initial revision
drewp
parents:
diff changeset
9
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 0
diff changeset
10
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
11 def bindkeys(root,key, func):
45b12307c695 Initial revision
drewp
parents:
diff changeset
12 root.bind(key, func)
45b12307c695 Initial revision
drewp
parents:
diff changeset
13 for w in root.winfo_children():
45b12307c695 Initial revision
drewp
parents:
diff changeset
14 w.bind(key, func)
45b12307c695 Initial revision
drewp
parents:
diff changeset
15
45b12307c695 Initial revision
drewp
parents:
diff changeset
16
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 0
diff changeset
17 def toplevelat(x,y,w=None,h=None):
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 0
diff changeset
18 tl=Toplevel()
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 0
diff changeset
19 if w and h:
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 0
diff changeset
20 tl.wm_geometry("%dx%d+%d+%d"%(w,h,x,y))
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 0
diff changeset
21 else:
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 0
diff changeset
22 tl.wm_geometry("+%d+%d"%(x,y))
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 0
diff changeset
23 return tl
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
24
45b12307c695 Initial revision
drewp
parents:
diff changeset
25
45b12307c695 Initial revision
drewp
parents:
diff changeset
26 def toggle_slider(s):
45b12307c695 Initial revision
drewp
parents:
diff changeset
27 if s.get() == 0:
45b12307c695 Initial revision
drewp
parents:
diff changeset
28 s.set(100)
45b12307c695 Initial revision
drewp
parents:
diff changeset
29 else:
45b12307c695 Initial revision
drewp
parents:
diff changeset
30 s.set(0)
45b12307c695 Initial revision
drewp
parents:
diff changeset
31
45b12307c695 Initial revision
drewp
parents:
diff changeset
32 # for lambda callbacks
45b12307c695 Initial revision
drewp
parents:
diff changeset
33 def printout(t):
45b12307c695 Initial revision
drewp
parents:
diff changeset
34 print t
45b12307c695 Initial revision
drewp
parents:
diff changeset
35
45b12307c695 Initial revision
drewp
parents:
diff changeset
36
45b12307c695 Initial revision
drewp
parents:
diff changeset
37 def colorlabel(label):
45b12307c695 Initial revision
drewp
parents:
diff changeset
38 """color a label based on its own text"""
45b12307c695 Initial revision
drewp
parents:
diff changeset
39 txt=label['text'] or "0"
45b12307c695 Initial revision
drewp
parents:
diff changeset
40 lev=float(txt)/100
45b12307c695 Initial revision
drewp
parents:
diff changeset
41 low=(80,80,180)
45b12307c695 Initial revision
drewp
parents:
diff changeset
42 high=(255,55,050)
45b12307c695 Initial revision
drewp
parents:
diff changeset
43 out = [int(l+lev*(h-l)) for h,l in zip(high,low)]
45b12307c695 Initial revision
drewp
parents:
diff changeset
44 col="#%02X%02X%02X" % tuple(out)
45b12307c695 Initial revision
drewp
parents:
diff changeset
45 label.config(bg=col)