[pygtk] Check if value-changed signal is emitted by user action

Seltzer squabbit7 at gmail.com
Wed Feb 27 01:09:25 WST 2008


I had the same poblem for a long time.
Right now we let the backend change the value normaly, and dont activate a
value changed callback.
For user interaction, we catch both the "button-press-event" and the
"button-release-event"
from the hscale.  When we catch a button press event, i unblock the
"value-changed" handler,
and when we catch a button release event i reblock the handler.

Basicly we only turn on the value-changed handler if the widget is being
directly interacted with.
...
value_cb_id   =3D  my_scale.get_adjustment().connect("value-changed",
value_cb)
my_scale.get_adjustment().handler_block(value_cb_id)
my_scale.connect("button-press-event",  my_callback, True)
my_scale.connect("button-release-event",  my_callback,  False)
...
def my_callback(widget,  event,  data):
    if data:
        my_scale.get_adjustment().handler_unblock(value_cb_id)
    else:
        my_scale.get_adjustment().handler_block(value_cb_id)
    return False
....

-felix


On Tue, Feb 26, 2008 at 9:26 AM, Dominic Sacr=E9 <dominic.sacre at gmx.de> wro=
te:

> Hi,
>
> Is it possible to determine if a value-changed signal (e.g. from a
> gtk.Scale)
> is caused by user action, or programmatically by calling set_value()? Or
> is
> there another way to achieve a similar effect?
>
> I'm using the value-changed callback to send the new value to my backend
> (asynchronously). But the GUI also needs to respond to notifications from
> the
> backend, by calling set_value().
> Now the GUI and the backend updating each other in this way causes all
> kinds
> of problems. I'd like to assume that if the value change is in response to
> a
> notification from the backend, there's no need to send the value to the
> backend again. Is there a reasonable way to accomplish this?
>
>
> Thanks,
>
> Dominic
> _______________________________________________
> pygtk mailing list   pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20080226/cbaad42c/at=
tachment.htm


More information about the pygtk mailing list