I do *not* see this behavior on
fedora-release-2-4 (Fedora Core 2 Linux)
python-2.3.3-6
tcl-8.4.5-7
tk-8.4.5-6
However, while dragging I can see a set to the same value multiple
times. I suppose this happens when the mouse movement is too small to
move one "resolution" unit.
You could use a class which acts as a function wrapper to eliminate the
redundant calls to "callback":
class RedundancyEliminator:
def __init__(self, var, callback):
self.var = var
self.callback = callback
self.lastval = var.get()
def __call__(self, *args):
newval = var.get()
if newval != self.lastval:
self.lastval = newval
return self.callback(*args)
return None
def callback(*args):
print var.get()
var.trace_variable("w", RedundancyEliminator(var, callback))
Jeff
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
iD8DBQFBJelwJd01MZaTXX0RArSpAJ9Ij30uC7atKEgic8y7J0 PngaSkYgCdEPSE
i+7amN/ajpcq8lwkUXIDCv4=
=iKhs
-----END PGP SIGNATURE-----
|