Hi,<div><br></div><div>I'm desperately trying to use uic.loadUi to load my main window into Python. I cannot get it to work for the main window, but it works fine for various widgets that are in the same Qt project. When I try to load the .ui file, I get the following error:</div>
<div><div>Traceback (most recent call last):</div><div> File "options.py", line 25, in <module></div><div> myapp = uic.loadUi('mainwindow.ui')</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/__init__.py", line 223, in loadUi</div>
<div> return DynamicUILoader(package).loadUi(uifile, baseinstance)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/Loader/loader.py", line 71, in loadUi</div><div> return self.parse(filename, basedir)</div>
<div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 929, in parse</div><div> actor(elem)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 770, in createUserInterface</div>
<div> self.traverseWidgetTree(elem)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 748, in traverseWidgetTree</div><div> handler(self, child)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 224, in createWidget</div>
<div> self.traverseWidgetTree(elem)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 748, in traverseWidgetTree</div><div> handler(self, child)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 459, in createLayout</div>
<div> self.traverseWidgetTree(elem)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 748, in traverseWidgetTree</div><div> handler(self, child)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 502, in handleItem</div>
<div> self.traverseWidgetTree(elem)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 748, in traverseWidgetTree</div><div> handler(self, child)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 224, in createWidget</div>
<div> self.traverseWidgetTree(elem)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 748, in traverseWidgetTree</div><div> handler(self, child)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 224, in createWidget</div>
<div> self.traverseWidgetTree(elem)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 748, in traverseWidgetTree</div><div> handler(self, child)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 459, in createLayout</div>
<div> self.traverseWidgetTree(elem)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 748, in traverseWidgetTree</div><div> handler(self, child)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 502, in handleItem</div>
<div> self.traverseWidgetTree(elem)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 748, in traverseWidgetTree</div><div> handler(self, child)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 459, in createLayout</div>
<div> self.traverseWidgetTree(elem)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 748, in traverseWidgetTree</div><div> handler(self, child)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 502, in handleItem</div>
<div> self.traverseWidgetTree(elem)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 748, in traverseWidgetTree</div><div> handler(self, child)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 224, in createWidget</div>
<div> self.traverseWidgetTree(elem)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 748, in traverseWidgetTree</div><div> handler(self, child)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 224, in createWidget</div>
<div> self.traverseWidgetTree(elem)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 748, in traverseWidgetTree</div><div> handler(self, child)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 459, in createLayout</div>
<div> self.traverseWidgetTree(elem)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 748, in traverseWidgetTree</div><div> handler(self, child)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 502, in handleItem</div>
<div> self.traverseWidgetTree(elem)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 748, in traverseWidgetTree</div><div> handler(self, child)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 459, in createLayout</div>
<div> self.traverseWidgetTree(elem)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 748, in traverseWidgetTree</div><div> handler(self, child)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 502, in handleItem</div>
<div> self.traverseWidgetTree(elem)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 748, in traverseWidgetTree</div><div> handler(self, child)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 224, in createWidget</div>
<div> self.traverseWidgetTree(elem)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 748, in traverseWidgetTree</div><div> handler(self, child)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 224, in createWidget</div>
<div> self.traverseWidgetTree(elem)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 748, in traverseWidgetTree</div><div> handler(self, child)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 459, in createLayout</div>
<div> self.traverseWidgetTree(elem)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 748, in traverseWidgetTree</div><div> handler(self, child)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 502, in handleItem</div>
<div> self.traverseWidgetTree(elem)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 748, in traverseWidgetTree</div><div> handler(self, child)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 215, in createWidget</div>
<div> self.stack.push(self.setupObject(widget_class, parent, elem))</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/uiparser.py", line 176, in setupObject</div><div> obj = self.factory.createQObject(clsname, name, args, is_attribute)</div>
<div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/objcreator.py", line 124, in createQObject</div><div> return self._cpolicy.instantiate(factory, *args, **kwargs)</div><div> File "/usr/lib/python2.7/site-packages/PyQt4/uic/Loader/qobjectcreator.py", line 131, in instantiate</div>
<div> return clsObject(*ctor_args)</div><div>TypeError: __init__() takes exactly 1 argument (2 given)</div></div><div><br></div><div><br></div><div>Here is the code I am trying to run:</div><div><br></div><div><div>class mainWindow(QtGui.QMainWindow):</div>
<div> def __init__(self,parent=None):</div><div> QtGui.QMainWindow.__init__(self, parent)</div><div> self.ui = uic.loadUi('mainwindow.ui', self)</div><div> </div><div><br></div><div>if __name__ == "__main__":</div>
<div> QtGui.QApplication.setStyle(QtGui.QStyleFactory.create("Cleanlooks"))</div><div> QtGui.QApplication.setPalette(QtGui.QApplication.style().standardPalette())</div><div> app = QtGui.QApplication(sys.argv)</div>
<div> myapp = mainWindow()</div><div> myapp.show()</div><div> sys.exit(app.exec_())</div></div><div><br></div><div>My google-fu is usually very strong, but I have been unable to determine the root of this problem. I have worked and worked on it, but still no luck. Please help!</div>
<div><br></div><div>Thanks,</div><div>Scott</div>