FAQ
Hi Everyone,

So I've used Glade to build a simple UI and I'm loading it with
gtkBuilder. The UI loads fine but, for some reason, none of my signals
are being connected. For example, in Glade, I said when the button
called btnExit was clicked, execute the btnExit_clicked method. Then, in
my App() class definition, I defined btnExit_clicked(self, widget) and
simply added the gtk.main_quit() statement (to exit). But when I start
my app, I am told that the btnExit_clicked() method isn't defined. This
happens for every single signal I define.

I'm assuming I'm simply putting something in the wrong place so can
anyone have a look at this and tell me what that might be? It looks
almost identical to examples I've seen on the net. Thanks!

CODE:

class App:
def __init__(self):
builder = gtk.Builder()
builder.add_from_file('bcbackup.ui')
builder.connect_signals({"on_window_destroy" : gtk.main_quit,
"on_btnExit_clicked" : btnExit_clicked})
self.window = builder.get_object("winMain")
self.window.show()

def btnSaveInformation_clicked(self, widget):
pass

def btnExit_clicked(self, widget):
gtk.main_quit()

if __name__ == "__main__":
myApp = App()
gtk.main()

END CODE

Search Discussions

  • Chris Hulan at Jul 11, 2011 at 3:33 pm
    The callback is a method so you need to specify the owner

    builder.connect_signals({"on_window_destroy" : gtk.main_quit,
    "on_btnExit_clicked" : self.btnExit_clicked})

    Got this info from http://www.pygtk.org/articles/pygtk-glade-gui/Creating_a_GUI_using_PyGTK_and_Glade.htm

    cheers

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJul 11, '11 at 6:42a
activeJul 11, '11 at 3:33p
posts2
users2
websitepython.org

2 users in discussion

Anthony Papillion: 1 post Chris Hulan: 1 post

People

Translate

site design / logo © 2022 Grokbase