@@ -123,7 +123,7 @@ def __init__(self, parent=None, **kw):
123123
124124 canvas .pack ()
125125 canvas .bind ('<ButtonRelease-1>' , self .__select_chip )
126- canvas .bind ('<B1-Motion>' , self .__select_chip )
126+ canvas .bind ('<B1-Motion>' , self .__drag_select_chip )
127127
128128 # Load a proc into the Tcl interpreter. This is used in the
129129 # set_color() method to speed up setting the chip colors.
@@ -162,6 +162,7 @@ def __init__(self, parent=None, **kw):
162162 assert self .__axis in (0 , 1 , 2 )
163163 self .initialiseoptions (StripWidget )
164164 self .__delegate = self ['delegate' ]
165+ self .__update_while_dragging = 1
165166
166167 def __set_color (self ):
167168 rgbtuple = self ['color' ]
@@ -182,17 +183,11 @@ def __select_chip(self, event=None):
182183 if chip and (1 <= chip [0 ] <= self .__numchips ):
183184 color = self .__chips [chip [0 ]- 1 ]
184185 rgbtuple = ColorDB .rrggbb_to_triplet (color )
185-
186186 self .__delegate .set_color (self , rgbtuple )
187- ## import profile
188- ## import pstats
189- ## import tempfile
190- ## statfile = tempfile.mktemp()
191- ## p = profile.Profile()
192- ## p.runcall(self.__delegate.set_color, self, rgbtuple)
193- ## p.dump_stats(statfile)
194- ## s = pstats.Stats(statfile)
195- ## s.strip_dirs().sort_stats('time').print_stats(10)
187+
188+ def __drag_select_chip (self , event = None ):
189+ if self .__update_while_dragging :
190+ self .__select_chip (event )
196191
197192 def __set_delegate (self ):
198193 self .__delegate = self ['delegate' ]
@@ -244,3 +239,6 @@ def set_color(self, obj, rgbtuple):
244239 else :
245240 outline = 'black'
246241 self .__canvas .itemconfigure (chip , outline = outline )
242+
243+ def set_update_while_dragging (self , flag ):
244+ self .__update_while_dragging = flag
0 commit comments