ok, ok, it works, 2 minutes after answering I've understood where to put
the if-clause. It seems gtk just needs to call the callback to update
the visual look of the widget, although it doesn't execute anything.

Sorry for previous mail and thanks a lot Christian.

So here is the code:

import gtk

class App:
  def __init__(self):
    self.opt = 1
    win = gtk.Window()
    win.set_size_request(100, 100)
    vbox = gtk.VBox()
    self.label = gtk.Label('Option: %d' % self.opt)
    vbox.pack_start(self.label)
    self.check = gtk.CheckButton('Check')
    self.check.set_active(self.opt)
    self.check.connect('toggled', self.onCheckToggled)
    vbox.pack_start(self.check)
    self.toggle = gtk.ToggleButton('Toggle')
    self.toggle.set_active(self.opt)
    self.toggle.connect('toggled', self.onToggleToggled)
    vbox.pack_start(self.toggle)
    win.add(vbox)
    win.show_all()
    self.block_toggle = 0

  def onCheckToggled(self, check):
    print self.opt,
    if not self.block_toggle:
      self.block_toggle = 1
      if self.opt:
        self.opt = 0
      else:
        self.opt = 1
      self.label.set_text('Option: %d' % self.opt)
      self.toggle.set_active(self.opt)
      self.block_toggle = 0
    print self.opt

  def onToggleToggled(self, toggle):
    print self.opt,
    if not self.block_toggle:
      self.block_toggle = 1
      if self.opt:
        self.opt = 0
      else:
        self.opt = 1
      self.label.set_text('Option: %d' % self.opt)
      self.check.set_active(self.opt)
      self.block_toggle = 0
    print self.opt

  def run(self):
    gtk.mainloop()

app = App()
app.run()

--
I�igo

Attachment: 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/

Reply via email to