tags:

views:

208

answers:

2

Hi! I'm working on a plugin for Avogadro (chemistry software) that uses pyqt. I've some problem with connecting a method to the clicked signal of a button. I've my class:

class Controller(object):
    def __init__(self):
        self.ui = MyDialog() # self.ui.run is a QPushButton
        self.ui.run.clicked.connect(self.on_run_click)
    def on_run_click(self):
        1/0

class MyDialog(QDialog,Ui_Dialog): # ui designer compiled
      def __init__(self):
         QDialog.__init__(self)
         self.setupUi(self)

Why when I click the button the on_run_click isn't called?

+1  A: 

Unless they've considerably changed something recently, this doesn't seem like the way to connect signals in PyQt. I'm more used to:

self.connect(self.ui.run, QtCore.SIGNAL("clicked()"),
             self, QtCore.SLOT("on_run_click()"))
Eli Bendersky
Thats the old style pyqt signal syntax. pygabriel used the new style syntax.
Philip Daubmeier
+1  A: 

The problem is that Avogadro python wrappers don't support the new signal syntax as described in Tim's blog post: http://timvdm.blogspot.com/2008/12/avogadro-gets-new-python-wrappers.html

pygabriel