[pygtk] Avoiding recursive event loops... or using better toggle buttons

Frederic Peters fpeters at entrouvert.com
Thu Mar 16 01:12:07 WST 2006


Ricardo Staudt wrote:

> Yes, exactly. Also if anyone can explain how I can also avoid the recursion
> problem when calling for events within event function, that would also be nice.

I hope I understood your problem; here is basically what I do:

  togglebutton1.connect('toggled', on_toggle_1)
  togglebutton2.connect('toggled', on_toggle_2)

  def on_toggle_1(widget):
      togglebutton2.set_active(not widget.get_active())
      if widget.get_active():
           pass # do this
      else:
           pass # do that

  def on_toggle_2(widget):
      togglebutton1.set_active(not widget.get_active())




        Frederic


More information about the pygtk mailing list