Howdy all,

I'm just learning pygtk and glade, and I have a question about
accessing widgets that were added during an called function. In my
example, I have two buttons. The first button that adds a checkbox to
a scrolled window area. The second button prints the activity status
(True/False) of the checkbox.

The first button works fine. However, when I push button two, python
says "AttributeError: 'NoneType' object has no attribute
'get_active'". Obviously, this means that I'm not reaching the
checkbox widget correctly.

So my question, how can I get properties of a widget added after the
initial glade file was loaded?

Here's my program, and I've attached my glade file. Thanks all!
-----------------------
import pygtk
import gtk
import gtk.glade

class app_gui:
  def __init__(self):
    self.window = gtk.glade.XML("check.glade")
    dic = { "on_button1_clicked" : self.button1_clicked,
            "on_button2_clicked" : self.button2_clicked,
            "on_window1_destroy" : (gtk.main_quit) }
    self.window.signal_autoconnect(dic)
    return

  def button1_clicked(self,widget):
    button = gtk.CheckButton("test")
    self.window.get_widget("scrolledwindow1").add_with_viewport(button)
    button.show()
    return

  def button2_clicked(self,widget):
    status = self.window.get_widget("test").get_active()
    print status
    return

app=app_gui()
gtk.main()
-----------------------

Avast!
Daniel Roesler
[email protected]

Attachment: check.glade
Description: application/glade

_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to