Changeset - d5deeed83228
[Not reviewed]
default
0 3 0
drewp - 22 years ago 2002-07-13 03:27:19

FancyDoubleVar is a DoubleVar where you can temporarily disable the callbacks
FancyDoubleVar is a DoubleVar where you can temporarily disable the callbacks
(at least the ones you made in python)
3 files changed with 26 insertions and 2 deletions:
0 comments (0 inline, 0 general)
light8/Lightboard.py
Show inline comments
 
@@ -156,13 +156,16 @@ class Lightboard:
 
        levels = [int(l) for l in levels]
 

	
 
        # load levels from external sliders
 
        extlevels = self.slidermapper.get_levels()
 
        for name, val in extlevels.items():
 
            if name in self.scalelevels:
 
                self.scalelevels[name].set(val)
 
                sl = self.scalelevels[name]
 
                sl.disable_traces()
 
                sl.set(val)
 
                sl.recreate_traces()
 
        
 
        for lev,lab,oldlev,numlab in zip(levels, self.channel_levels, 
 
                                         self.oldlevels, 
 
                                         self.leveldisplay.number_labels):
 
            if lev != oldlev:
 
                lab.config(text="%d" % lev) # update labels in lev display
light8/panels.py
Show inline comments
 
@@ -132,13 +132,13 @@ class Subpanels:
 
            f.pack(fill='both',exp=1,side=side2)
 
            
 

	
 
            # make DoubleVar (there might be one left around from
 
            # before a refresh)
 
            if name not in scalelevels:
 
                scalelevels[name]=DoubleVar()
 
                scalelevels[name]=FancyDoubleVar()
 

	
 
            sub.set_slider_var(scalelevels[name])
 

	
 
            scaleopts = {'troughcolor' : 'grey70'}
 
            if sub.color:
 
                scaleopts['troughcolor'] = sub.color
light8/uihelpers.py
Show inline comments
 
@@ -150,12 +150,33 @@ class Togglebutton(Button):
 
        if newstate: # set
 
            self.config(bg=self.downcolor,relief='sunken')
 
        else: # unset
 
            self.config(bg=self._origbkg,relief='raised')
 
        return "break"
 

	
 

	
 
class FancyDoubleVar(DoubleVar):
 
    def __init__(self,master=None):
 
        DoubleVar.__init__(self,master)
 
        self.callbacklist = {}
 
    def trace_variable(self,mode,callback):
 

	
 
        # we build a list of the trace callbacks (the py functrions and the tcl functionnames)
 
        id=DoubleVar.trace_variable(self,mode,callback)
 

	
 
        self.callbacklist[id]= [mode,callback]
 

	
 
        return id
 

	
 
    def disable_traces(self):
 
        for k,v in self.callbacklist.items():
 
            self.trace_vdelete(v[0],k)
 
    def recreate_traces(self):
 
        for k,v in self.callbacklist.items():
 
            self.trace_variable(v[0],v[1])
 

	
 
if __name__=='__main__':
 
    root=Tk()
 
    root.tk_focusFollowsMouse()
 
    iv=IntVar()
 
    def cb():
 
        print "cb!"
0 comments (0 inline, 0 general)