Why are my signals being ignored?

Anthony Papillion papillion at gmail.com
Wed Jun 22 21:39:12 EDT 2011


Hello Everyone,

So I figured out the last problem about why I couldn't load my UI files but
now I've got something that has be totally stumped. I've worked on it most
of the day yesterday, Google'd it, and fought with it today and I'm
admitting defeat and coming to the group with hat in hand asking for help.

For some reason, in the code below, my signals are being completely ignored.
For example, you'll notice that I connected the 'btnExit' to the method
called 'clickedButton()' but, for some reason, when the button is clicked,
the method is never called. I've been following tutorials and this seems to
be the proper way to wire signals yet mine simply don't work.

Would anyone be so kind as to look over the following code and give me a bit
of advice (or direction) as to what I might be doing wrong?

Thanks!
Anthony

Code:

#!/usr/bin/env python

import sys

try:
import pygtk
 pygtk.require("2.0")
except:
print "Error. PYGTK could not be loaded."
 sys.exit(1)
try:
import gtk
import gtk.glade
except:
print "GTK not present or not loaded."
sys,exit(1)
 class TestClass(object):
 def __init__(self):
 self.uiFile = "MainWindow.glade"
self.wTree = gtk.Builder()
self.wTree.add_from_file(self.uiFile)
 self.window = self.wTree.get_object("winMain")
if self.window:
 self.window.connect("destroy", gtk.main_quit)
 dic = { "on_btnExit_clicked" : self.clickButton, "on_winMain_destroy" :
gtk.main_quit }
 self.wTree.connect_signals(dic)
self.window.show()
else:
 print "Could not load window"
sys.exit(1)
  def clickButton(self, widget):
print "You clicked exit!"
  def exit(self, widget):
 gtk.main_quit()
 def update_file_selection(self, widget, data=None):
 selected_filename = FileChooser.get_filename()
print selected_filename
 if __name__ == "__main__":
Tester = TestClass()
gtk.main()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110622/8a34dc2a/attachment.html>


More information about the Python-list mailing list