[pygtk] strange spinbutton behavior

James Dietrich jdietrch at gmail.com
Thu Jun 28 21:21:57 WST 2007


On 6/27/07, Tim Evans <t.evans at aranz.com> wrote:
[snip]
> I think what might be happening is that the spinbutton arrow is thought
> of as pressed until your callback finishes and GTK can go back to
> handling events.  Now, if spinbutton arrows are held down, they have a
> repeat like the normal keyboard repeat.  GTK registers the button as
> being held down for a while and a repeat sneaks in there.
>
> If this is the cause then you can fix it by moving the main work of your
> handler to an idle callback, something like this:
>
> def adj_callback(adj):
>      gobject.idle_add(_real_adj_callback)
>
> def _real_adj_callback():
>      gtk.gdk.threads_enter()
>      try:
>          for x in range(10000000):
>              y = x * x
>          return False
>      finally:
>          gtk.gdk.threads_leave()
>
> The threads enter/leave calls aren't needed if you're not using
> threading, but for an action that can take several seconds you should
> probably look at using them.

That took care of it!  Thank you very much for your help.

James Dietrich


More information about the pygtk mailing list