开发者

My signals are being ignored!

开发者 https://www.devze.com 2023-03-15 02:06 出处:网络
So I developed a UI in Glade and am coding the program in Python. For some reason, all of my signals are being ignored! Though I\'ve connected them correctly (I think), clicking on the buttons does ab

So I developed a UI in Glade and am coding the program in Python. For some reason, all of my signals are being ignored! Though I've connected them correctly (I think), clicking on the buttons does absolutely nothing!

Below is the code that I'm using to load the ui and connect the signals. Can anyone see WHY they might be being ignored?

class mySampleClass(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__":
MyApp = MySampleClass()
gtk.main()


I'm not completely sure that this is the answer, but I know that a number of PyGTK objects cannot send signals themselves - gtk.Image and gtk.Label are two such examples. The solution is to place the widget inside of an event box (gtk.EventBox) and link the events to that.

I do not know if this is the case with tree objects, however. All the same, worth investigating, imho.

0

精彩评论

暂无评论...
验证码 换一张
取 消