[PyQt] BUG: uiparser.py:161: AttributeError: 'module' object has no attribute 'StackedWidget'
Phil Thompson
phil at riverbankcomputing.com
Tue Jan 11 09:12:45 GMT 2011
On Tue, 11 Jan 2011 04:04:50 +0300, Vladimir Rutsky
<rutsky.vladimir at gmail.com> wrote:
> Hello,
>
> Installed on Windows XP Python v2.7.1 and PyQt v4.8.1 for Python 2.7.
> Running of following code that creates simple window from UI file raises
> AttributeError:
>
> # main.py
> import sys
>
> from PyQt4 import QtGui, uic
>
> class MainWindow(QtGui.QMainWindow):
> def __init__(self, parent=None):
> super(MainWindow, self).__init__(parent)
>
> uic.loadUi('main_window.ui', self)
>
> if __name__ == "__main__":
> app = QtGui.QApplication(sys.argv)
>
> w = MainWindow()
> w.show()
>
> sys.exit(app.exec_())
> # end of main.py
>
> Raised exception:
> Traceback (most recent call last):
> File "main.py", line 14, in <module>
> w = MainWindow()
> File "main.py", line 9, in __init__
> uic.loadUi('main_window.ui', self)
> File "C:\Python27\lib\site-packages\PyQt4\uic\__init__.py", line 185,
> in loadUi
> return DynamicUILoader().loadUi(uifile, baseinstance)
> File "C:\Python27\lib\site-packages\PyQt4\uic\Loader\loader.py", line
> 35, in loadUi
> return self.parse(filename, basedir)
> File "C:\Python27\lib\site-packages\PyQt4\uic\uiparser.py", line 839,
> in parse
> actor(elem)
> File "C:\Python27\lib\site-packages\PyQt4\uic\uiparser.py", line 686,
> in createUserInterface
> self.traverseWidgetTree(elem)
> File "C:\Python27\lib\site-packages\PyQt4\uic\uiparser.py", line 664,
> in traverseWidgetTree
> handler(self, child)
> File "C:\Python27\lib\site-packages\PyQt4\uic\uiparser.py", line 161,
> in createWidget
> QtGui.QScrollArea, QtGui.StackedWidget,
> AttributeError: 'module' object has no attribute 'StackedWidget'
>
> Commenting "QtGui.QScrollArea, #QtGui.StackedWidget," in uiparser.py:161
> fixes this issue for me.
The correct fix is to change "StackedWidget" to "QStackedWidget".
> Same example works without any modifications on GNU/Linux (Ubuntu 10.04)
> with Python v2.6.5 and PyQt v4.7.2-0ubuntu1.
>
> P.S. Is somewhere exists bug tracker for PyQt?
>
> Regards,
> Vladimir Rutsky
Phil
More information about the PyQt
mailing list