Hi, There appears to be an error in the loading of .ui files in PyQt5. Please try the attached example.
Error message: Traceback (most recent call last): File "D:\eclipse.workspace\py_tests\src\uic_bug.py", line 15, in <module> window = LogWindow() File "D:\eclipse.workspace\py_tests\src\uic_bug.py", line 8, in __init__ PyQt5.uic.loadUi(os.path.join(os.path.dirname(__file__), 'log_window.ui'), self) File "D:\_cpp_projects_\Python\Python-3.3.1\lib\site-packages\PyQt5\uic\__init__.py", line 224, in loadUi return DynamicUILoader(package).loadUi(uifile, baseinstance, resource_suffix) File "D:\_cpp_projects_\Python\Python-3.3.1\lib\site-packages\PyQt5\uic\Loader\loader.py", line 72, in loadUi return self.parse(filename, resource_suffix, basedir) File "D:\_cpp_projects_\Python\Python-3.3.1\lib\site-packages\PyQt5\uic\uiparser.py", line 931, in parse actor(elem) File "D:\_cpp_projects_\Python\Python-3.3.1\lib\site-packages\PyQt5\uic\uiparser.py", line 756, in createUserInterface self.traverseWidgetTree(elem) File "D:\_cpp_projects_\Python\Python-3.3.1\lib\site-packages\PyQt5\uic\uiparser.py", line 734, in traverseWidgetTree handler(self, child) File "D:\_cpp_projects_\Python\Python-3.3.1\lib\site-packages\PyQt5\uic\uiparser.py", line 444, in createLayout self.stack.push(self.setupObject(classname, parent, elem)) File "D:\_cpp_projects_\Python\Python-3.3.1\lib\site-packages\PyQt5\uic\uiparser.py", line 161, in setupObject self.wprops.setProperties(obj, branch) File "D:\_cpp_projects_\Python\Python-3.3.1\lib\site-packages\PyQt5\uic\properties.py", line 415, in setProperties getattr(widget, "set%s%s" % (ascii_upper(prop_name[0]), prop_name[1:]))(prop_value) AttributeError: 'QHBoxLayout' object has no attribute 'setMargin' The log_window.ui instantiates a QHBoxLayout, with all margins set to the same value. This makes the uic module try to set a "margin" property, which doesn't exist. Setting one of the margins (for example "leftMargin") to a different value works. Best Regards, Mathias Born
log_window.ui
Description: Binary data
from PyQt5.QtWidgets import * import PyQt5.uic, sys, os.path class LogWindow(QFrame): def __init__(self): QFrame.__init__(self) PyQt5.uic.loadUi(os.path.join(os.path.dirname(__file__), 'log_window.ui'), self) if __name__ == '__main__': import sys app = QApplication(sys.argv) window = LogWindow() window.show() app.exec_()
_______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt