[pygtk] Toggle menu item and toggle button syncronized
A.T.Hofkamp
a.t.hofkamp at tue.nl
Mon May 8 22:30:33 WST 2006
Hello all,
Adolfo González Blázquez wrote:
> Hello,
>
> I'm trying to syncronize a toggle menu item, and a toggle button, so
> when one of them is activated, the other one gets activated as well.
>
> The problem comes when cliking the menu item, i try to activate the
> button, and this catch the 'clicked' signal, so it tries to activate the
> menu, and that si a kind of infinite loop.
> Maybe i'm not explaining myself clearly...
>
> The code is like this:
>
> def on_menu_play_clicked(self, widget):
> self.playing = not self.playing
> self.button_play.set_activated(self.playing)
> self.play()
>
> def on_button_play_clicked(self, widget):
> self.playing = not self.playing
> self.play()
In Qt, they solved this by including the desired state in the call, and only
forwarding the call when the desired state is different than the current state.
Alternatively, instead of two functions that call each other, you may have one
doing all the work (both updating widgets and setting/resetting state).
Albert
More information about the pygtk
mailing list