[PyQt] BUG: uiparser.py:161: AttributeError: 'module' object has no attribute 'StackedWidget'

Vladimir Rutsky rutsky.vladimir at gmail.com
Tue Jan 11 01:04:50 GMT 2011


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.

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.py
Type: text/x-python
Size: 338 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110111/51ead1f4/attachment.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main_window.ui
Type: application/x-designer
Size: 847 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110111/51ead1f4/attachment.bin>


More information about the PyQt mailing list