[Eric] Basic button signal question

Phil phil_lor at bigpond.com
Mon Feb 18 04:08:13 GMT 2013


Thank you for reading this.

I've created a basic GUI with a button and using Designer's slot editor 
I have generated the code for the slot. The problem is I don't know 
where to go from here. I'm familiar with Designer and C++ under Qt Creator.

This is from Ui_mainwindow.py:

class Ui_MainWindow(object):
     def setupUi(self, MainWindow):
         MainWindow.setObjectName(_fromUtf8("MainWindow"))
         MainWindow.resize(200, 200)
         self.centralWidget = QtGui.QWidget(MainWindow)
         self.centralWidget.setObjectName(_fromUtf8("centralWidget"))
         self.pushButton = QtGui.QPushButton(self.centralWidget)
         self.pushButton.setGeometry(QtCore.QRect(40, 80, 91, 24))
         self.pushButton.setObjectName(_fromUtf8("pushButton"))
         MainWindow.setCentralWidget(self.centralWidget)

         self.retranslateUi(MainWindow)
         QtCore.QObject.connect(self.pushButton, 
QtCore.SIGNAL(_fromUtf8("toggled(bool)")), MainWindow.buttonToggledSlot)
         QtCore.QMetaObject.connectSlotsByName(MainWindow)


And this is mainwindow.py:

     @pyqtSignature("bool")
     def on_pushButton_toggled(self, checked):
         """
         Slot documentation goes here.
         """
         # TODO: not implemented yet
         raise NotImplementedError

How do I implement the button toggled slot?

-- 
Regards,
Phil


More information about the Eric mailing list