Tkinter: user vs. program events
Jerry
2jerry at writeme.com
Tue Feb 22 17:29:54 EST 2000
Well one or tow ideas .. get them as there are :-)
- first you can disable callback on set() when user "come in" the widget
scale with cursor
to protect automatic activity use binding <Enter> and <Leave> for
disable/enable
- second: protect the set methode with intermediate class which
inheritate from Tkinter Var class.
hum .. no more idea, no time to investigate more or give example , sorry ..
If i can found some time .. I'll write a snippet for that.
Jerry the foolish dracomorpheus, Jérôme VACHER- france-
Andrew M. Kuchling a écrit dans le message
<3d1z65kr2j.fsf at amarok.cnri.reston.va.us>...
>I've been trying to figure out how to distinguish between Tkinter
>events that come from a user and ones that originate from changing the
>value of a widget. Is this possible?
>
>Here's the motivating example. I have a Scale widget for indicating
>light intensity:
>
> self.light_scale = Tkinter.Scale(f, command = self.adjust_light)
>
>adjust_light() is a method that takes the current value of the scale
>widget, and sends off a command to change light intensity. The
>Tkinter program also receives updates on the current state, and
>changes the scale widget to match the current value, with
>self.light_scale.set( <value> ) .
>
>The problem is that the light_scale.set() call causes the associated
>command to be run, so a command is sent off changing the light
>intensity, which causes another status update to be sent out, which
>changes the setting, and so forth.
>
>So, how would you do this in Tkinter? Can I distinguish between
>events generated by a user and by a .set() call? Should
>adjust_light() be bound to some different event? Or should I change
>the binding of the widget on every update()?
>
>--
>A.M. Kuchling http://starship.python.net/crew/amk/
>Science itself, therefore, may be regarded as a minimal problem, consisting
of
>the completest possible presentment of facts with the least possible
>expenditure of thought.
> -- Ernst Mach
>
More information about the Python-list
mailing list