[PyQt] Bug: PyQt5.uic.loadUi() attempts to set non-existing property
Mathias.Born at gmx.de
Mathias.Born at gmx.de
Sun Jun 2 18:28:42 BST 2013
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: log_window.ui
Type: application/octet-stream
Size: 1696 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20130602/e4c2adc7/attachment.obj>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: uic_bug.py
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20130602/e4c2adc7/attachment.ksh>
More information about the PyQt
mailing list