Mikael Lindqvist wrote:
> Hello,
> 
> Is there a way of distinguishing if the value of a control is changed
> by the user or by code in some part of my program?
> 
> To clarify, I'm setting the value of a spinbutton with code, i.e.
> spinbutton.set_value(...) . This causes the value_changed signal to be
> sent to my program. The behavior is the same as when a user modifies
> the value. In the callback I need to be able to distinguishing what
> caused the signal to be fired. Is this possible? Or, better yet, is it
> possible somehow to not have the signal fired when you set the value
> programatically?

I'm not sure I undestand you:

Python 2.3.5 (#2, Oct 16 2006, 19:19:48)
[GCC 3.3.5 (Debian 1:3.3.5-13)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> import gtk
>>> adjustment = gtk.Adjustment ()
>>> handler = lambda adjustment: sys.stdout.write ("%s %i\n" % (adjustment, 
>>> adjustment.value))
>>> adjustment.connect ("value-changed", handler)
1
>>> adjustment.upper = 10
>>> adjustment.value = 5
<gtk.Adjustment object (GtkAdjustment) at 0x401ece64> 5

SpinButton signals look the same.  If you want to connect a method of
specific object, use

        spin_button.connect ("value-changed", the_object.handle_value_changed)

Paul
_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to