comparison light8/uihelpers.py @ 58:a4d000f759b4

new event handling utils
author drewp
date Tue, 09 Jul 2002 07:35:57 +0000
parents 065896b0913c
children 2508c6b7a4e0
comparison
equal deleted inserted replaced
57:eaf60f5dce86 58:a4d000f759b4
30 s.set(0) 30 s.set(0)
31 31
32 # for lambda callbacks 32 # for lambda callbacks
33 def printout(t): 33 def printout(t):
34 print t 34 print t
35
36 def printevent(ev):
37 for k in dir(ev):
38 if not k.startswith('__'):
39 print k,getattr(ev,k)
40 print ""
35 41
42 def eventtoparent(ev,sequence):
43 "passes an event to the parent"
44 evdict={}
45 for x in ['state', 'time', 'y', 'x', 'serial']:
46 evdict[x]=getattr(ev,x)
47 # evdict['button']=ev.num
48 par=ev.widget.winfo_parent()
49 if par!=".":
50 ev.widget.nametowidget(par).event_generate(sequence,**evdict)
51 #else the event made it all the way to the top, unhandled
52
53 def scrollscrolledwindow(widget,amount):
54 print "scroll",widget,amount
55
56
36 def colorlabel(label): 57 def colorlabel(label):
37 """color a label based on its own text""" 58 """color a label based on its own text"""
38 txt=label['text'] or "0" 59 txt=label['text'] or "0"
39 lev=float(txt)/100 60 lev=float(txt)/100
40 low=(80,80,180) 61 low=(80,80,180)