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
 
@@ -159,7 +159,10 @@ class Lightboard:
 
        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, 
light8/panels.py
Show inline comments
 
@@ -135,7 +135,7 @@ class Subpanels:
 
            # 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])
 

	
light8/uihelpers.py
Show inline comments
 
@@ -153,6 +153,27 @@ class Togglebutton(Button):
 
            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()
0 comments (0 inline, 0 general)