<br>I've made a simple gui that has just a few widgets on it using QTDesigner<br>I was able to preview the code in QtDesigner<br><br>I'm trying to launch it now from a command line script, using this example on Riverbank's page
<br><br><a href="http://www.riverbankcomputing.com/Docs/PyQt4/pyqt4ref.html#using-the-generated-code">http://www.riverbankcomputing.com/Docs/PyQt4/pyqt4ref.html#using-the-generated-code</a><br>The first example shows the direct approach where we simply create a simple
application to create the dialog:
<pre class="literal-block">import sys<br>from PyQt4 import QtGui<br>from ui_imagedialog import Ui_ImageDialog<br><br>app = QtGui.QApplication(sys.argv)<br>window = QtGui.QDialog()<br>ui = Ui_ImageDialog()<br>ui.setupUi(window)
<br><br>window.show()<br>sys.exit(app.exec_())<br></pre><br>I've substituted Ui_ImageDialog with the class generated by QTDesigner<br><br>from PyQt4 import QtCore, QtGui<br>from mainwindow import Ui_MainWindow<br><br>
class MainWindow(QtGui.QDialog):<br> def __init__(self):<br> app = QtGui.QApplication(sys.argv)<br> window = QtGui.QDialog()<br> self.ui = Ui_MainWindow()<br> self.ui.setupUi(window)<br>
window.show()<br> sys.exit(app.exec_()) <br><br>mainwindow = MainWindow()<br><br><br>however, I get this error, which I dont understand.<br><br>Traceback (most recent call last):<br> File "maingui.py", line 16, in ?
<br> mainwindow = MainWindow()<br> File "maingui.py", line 12, in __init__<br> self.ui.setupUi(window)<br> File "C:\Code\mainwindow.pyw", line 227, in setupUi<br> MainWindow.setCentralWidget
(self.centralwidget)<br>AttributeError: setCentralWidget<br><br><br>Would someone explain what I'm doing wrong?<br><br><br><br>