Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: [Tkinter-discuss] Please help -- Tkinter Scale widget withDoubleVar is acting weird

Reply
Thread Tools

Re: [Tkinter-discuss] Please help -- Tkinter Scale widget withDoubleVar is acting weird

 
 
Jeff Epler
Guest
Posts: n/a
 
      08-20-2004
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-----

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tkinter.event.widget: handler gets name instead of widget. Frederic Rentsch Python 0 07-08-2012 09:19 PM
Is there a Tkinter widget like Scale with two sliders? WLigtenberg@gmail.com Python 0 11-20-2007 09:08 AM
Re: [Tkinter-discuss] Please help -- Tkinter Scale widget withDoubleVar is acting weird Jeff Epler Python 0 08-23-2004 02:31 PM
Re: Please help -- Tkinter Scale widget with DoubleVar is actingweird Fredrik Lundh Python 0 08-19-2004 05:01 PM
Tkinter, scale widget, and mouse clicks John Fouhy Python 2 06-25-2004 12:49 AM



Advertisments