So I tried setting up a simple button widget->main window (ground symbol) signal->slot. Once doing so, I edit in a custom slot name, which I will add to the class later.
Basic Example:
Connecting pushButton.clicked()->MyMainWindow.my_slot()
class Ui_MyMainWindow(object):
def setupUi(self, MyMainWindow):
MyMainWindow.setObjectName(_fromUtf8("MyMainWindow"))
MyMainWindow.setEnabled(True)
MyMainWindow.resize(537, 349)
...
self.pushButton = QtGui.QPushButton(self.centralwidget)
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.horizontalLayout.addWidget(self.pushButton)
MyMainWindow.setCentralWidget(self.centralwidget)
'''PROBLEM MyMainWindow.my_slot() in the following line should be
Ui_MyMainWindow.my_slot so slot/function belongs to the class
or even without a parent so I can do a ''from my_existing_module import *''.
For widget->widget calls, this way of linking makes sense, but
if I just want to call some pre-written function, it doesnt
work without stupid hand editing'''
QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL(_fromUtf8("clicked()")), MyMainWindow.my_slot)
QtCore.QMetaObject.connectSlotsByName(MyMainWindow)
...
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
MyMainWindow = QtGui.QMainWindow()
ui = Ui_MyMainWindow()
ui.setupUi(MyMainWindow)
MyMainWindow.show()
sys.exit(app.exec_())
I tried looking into the compiler.py file and other related ones to see if I could modify the argument name of setupUi but I got lost in all the calls to imported functions and jumping back and forth between files. I mostly just broke things. Thank god for backups.