Osmo Maatta | 21 Nov 20:50

Setting value of gtk.SpinButton without triggering the "value-changed" event.

Hello,

I need to change the self.width_spin (gtk.SpinButton) value, but in some cases I do not want the changed event to fire. How do I set the value?  This is my code:

        adj = gtk.Adjustment(orig_width, 1, orig_width, 1, 50, 0)
        self.width_spin = gtk.SpinButton(adj, climb_rate=0.0, digits=0)
        self.width_spin.show()
        self.width_spin.set_numeric(True)
        self.width_spin.connect("value-changed", self.image_size_changed_callback, "width")
        hbox1.pack_start(self.width_spin, False, False, 0)

This call will trigger the "value-changed" event so I want to avoid it.
    self.width_spin.set_value(some_value)

gtk.SpinButton is derived from gtk.Entry, so if I could grab the entry field from gtk.SpinButton so it may be possible to write:
entry.set_data("value", some_value)

Do you know how to do this right?

Am writing a filter/resize/and scale plugin in Python for my screendump program http://bildr.no/view/291282. Screendump is written in GTK and c.

TIA
  Osmo Antero (moma)
  Oslo

_______________________________________________
pygtk mailing list   pygtk <at> daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
Paul Pogonyshev | 21 Nov 21:04

Re: Setting value of gtk.SpinButton without triggering the "value-changed" event.

Osmo Maatta wrote:
> I need to change the self.width_spin (gtk.SpinButton) value, but in some 
> cases I do not want the changed event to fire. [...]

Actually you don't.  There can be some handlers that you don't know of,
e.g. GTK+ itself can install some handlers for its own purposes.  Then,
if you slip some value change in without the corresponding signal, the
code behind such handlers can break in unpredictable manner.

What you should do instead is to block handlers you don't want to be
run during this change and unblock them afterwards (or disconnect and
the reconnect again).  Or maybe set some internal boolean variable
which means "ignore this change" for your handlers.

Paul
_______________________________________________
pygtk mailing list   pygtk <at> daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Communication between apps

I am developing a package manager on python (actually a GUI for an existing package manager).

The issue is i don't want users to be able to run 2 instances of my application (integrity stuff .. u know). So far I have managed to prevent users to do so .. and that's cool, but it would be even cooler if, instead of showing an Error dialog saying there is one instance already running, ii show the running instance --give it the focus or something like that-- ..

any clues??

cheers!!


--
Daniel Hernández Bahr
Universidad de las Ciencias Informáticas.

_______________________________________________
pygtk mailing list   pygtk <at> daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Gmane