comparison light8/uihelpers.py @ 52:065896b0913c

emergency commit
author dmcc
date Mon, 08 Jul 2002 03:25:42 +0000
parents 71489bb71528
children a4d000f759b4
comparison
equal deleted inserted replaced
51:71489bb71528 52:065896b0913c
58 class Togglebutton(Button): 58 class Togglebutton(Button):
59 """works like a single radiobutton, but it's a button so the 59 """works like a single radiobutton, but it's a button so the
60 label's on the button face, not to the side. the optional command 60 label's on the button face, not to the side. the optional command
61 callback is called on button set, not on unset. takes a variable 61 callback is called on button set, not on unset. takes a variable
62 just like a checkbutton""" 62 just like a checkbutton"""
63 def __init__(self,parent,variable=None,command=None,**kw): 63 def __init__(self,parent,variable=None,command=None,downcolor='red',**kw):
64 64
65 self.oldcommand = command 65 self.oldcommand = command
66 Button.__init__(self,parent,command=self.invoke,**kw) 66 Button.__init__(self,parent,command=self.invoke,**kw)
67 67
68 self._origbkg = self.cget('bg') 68 self._origbkg = self.cget('bg')
69 self.downcolor = downcolor
69 70
70 self._variable = variable 71 self._variable = variable
71 if self._variable: 72 if self._variable:
72 self._variable.trace('w',self._varchanged) 73 self._variable.trace('w',self._varchanged)
73 self._setstate(self._variable.get()) 74 self._setstate(self._variable.get())
92 return "break" 93 return "break"
93 94
94 def _setstate(self,newstate): 95 def _setstate(self,newstate):
95 self.state = newstate 96 self.state = newstate
96 if newstate: # set 97 if newstate: # set
97 self.config(bg='red',relief='sunken') 98 self.config(bg=self.downcolor,relief='sunken')
98 else: # unset 99 else: # unset
99 self.config(bg=self._origbkg,relief='raised') 100 self.config(bg=self._origbkg,relief='raised')
100 return "break" 101 return "break"
101 102
102 if __name__=='__main__': 103 if __name__=='__main__':