first, thanks for the help, but it doesn't work. El mar, 09-09-2003 a las 16:36, Christian Reis escribi�: > The correct answer to your inquiry is, of course, "Why do you want to do > that?"; however:
I want to control the state of a varible (in fact, the visibility of the
grid of the second question) from two places: CheckButton in a menu
entry and ToggleButton in the UI.
> On Tue, Sep 09, 2003 at 04:28:36PM +0200, I�igo Serna wrote:
> > I have a problem when sharing a value depending on the state of 2
> > widgets.
>
> You have the answer in your hand: you need to use a shared lock
> variable.
>
> > def onCheckToggled(self, check):
> > print self.opt,
> > if self.opt:
> > self.opt = 0
> > else:
> > self.opt = 1
> > print self.opt,
> > self.label.set_text('Option: %d' % self.opt)
>
> if not self.block_toggle:
>
> self.block_toggle = 1
>
> > self.toggle.set_active(self.opt)
>
> self.block_toggle = 0
>
> > print self.opt
>
> -- and the same code here
>
> > def onToggleToggled(self, toggle):
> > print self.opt,
> > if self.opt:
> > self.opt = 0
> > else:
> > self.opt = 1
> > self.label.set_text('Option: %d' % self.opt)
>
> if not self.block_toggle:
>
> self.block_toggle = 1
>
> > self.check.set_active(self.opt)
>
> self.block_toggle = 0
>
The problem comes because when self.toggle.set_active(self.opt) is
executed in onCheckToggled method, self.opt value has already changed to
the new value, but self.toggle.set_active(self.opt) calls
onToggleToggled method, which changes self.opt a second time.
What I want is to update the visual aspect of the 2nd widget
(ToggleButton), but do so I have to call widget.set_active or
widget.set_property which calls onToggleButton and this modifies opt
variable a second time.
There is also a problem about cyclical calls between onCheckButton and
onToggleButton methods.
Any idea?
Thanks,
I�igo
signature.asc
Description: Esta parte del mensaje =?ISO-8859-1?Q?est=E1?= firmada digitalmente
_______________________________________________ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
