I spoke too soon! I have added a button to the script, but it causes an error even though the names are correct, as you can see from the script below and the attached files.
#! /usr/bin/python
import sys
from PyQt4 import QtCore, QtGui
from pyuic_ui import Ui_MainWindow
def __init__(self, parent=None):
QtGui.
QWidget.__init__
(self, parent
) self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.buttonProcess.triggered.connect(self.buttonProcessTriggered)
def buttonProcessTriggered(self):
print 'OK'
if __name__ == "__main__":
mywindow = MyWindowClass()
mywindow.show()
sys.exit(app.exec_())
#! /usr/bin/python
import sys
from PyQt4 import QtCore, QtGui
from pyuic_ui import Ui_MainWindow
class MyWindowClass(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.buttonProcess.triggered.connect(self.buttonProcessTriggered)
def buttonProcessTriggered(self):
print 'OK'
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
mywindow = MyWindowClass()
mywindow.show()
sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode
chris@Asus:~/Documents/Linux/Debreate/PyQt$ ./pyuic.py
Traceback (most recent call last):
File "./pyuic.py", line 23, in <module>
mywindow = MyWindowClass()
File "./pyuic.py", line 13, in __init__
buttonProcess.triggered.connect(self.buttonProcessTriggered)
NameError: global name 'buttonProcess' is not defined
chris@Asus:~/Documents/Linux/Debreate/PyQt$ ./pyuic.py
Traceback (most recent call last):
File "./pyuic.py", line 23, in <module>
mywindow = MyWindowClass()
File "./pyuic.py", line 13, in __init__
buttonProcess.triggered.connect(self.buttonProcessTriggered)
NameError: global name 'buttonProcess' is not defined
To copy to clipboard, switch view to plain text mode
There is also a strange anomaly with Qt, in that stuff I have deleted from the GUI with Qt Creator doesn't always get deleted from the .ui file. You can see from the attached files that there is only a button on the gui, but unwanted lines remain in the .ui file.
Bookmarks