Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Please help -- Tkinter Scale widget with DoubleVar is actingweird

Reply
Thread Tools

Re: Please help -- Tkinter Scale widget with DoubleVar is actingweird

 
 
Fredrik Lundh
Guest
Posts: n/a
 
      08-19-2004
Jared Cohen wrote:

> Hi all. I'm currently using a Tkinter Scale widget which uses a
> DoubleVar as its control variable. I then use the "trace_variable('w',
> callback)" method to invoke a callback whenever the DoubleVar changes.
>
> The problem is this: the callback is triggered when the slider moves (as
> it should), but it's also triggered when I just HOVER the mouse over the
> slider without clicking! Somehow or other, it must think that the
> control variable is being changed, even though it isn't. I *think* that
> this problem is related to the loss of precision that DoubleVars can
> have, but I'm not really sure. Has anyone else experienced this problem?
> How can I fix this?


you could use a "command" callback instead of a traced variable:

import sys, Tkinter, types

root = Tkinter.Tk()

def callback(value):
print float(value)

slider = Tkinter.Scale(root,
from_ = 0.0,
to = 1.0,
resolution = 0.1,
command = callback,
orient = 'horizontal')
slider.grid(sticky='ew')

root.mainloop()

(use slider.get() to get the current value from outside the callback,
and slider.set(x) to set it).

</F>



 
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: [Tkinter-discuss] Please help -- Tkinter Scale widget withDoubleVar is acting weird Jeff Epler Python 0 08-20-2004 12:07 PM
Tkinter, scale widget, and mouse clicks John Fouhy Python 2 06-25-2004 12:49 AM



Advertisments