[PyQt] Bug: PyQt5.uic.loadUi() attempts to set non-existing property

Phil Thompson phil at riverbankcomputing.com
Sun Jun 2 23:45:56 BST 2013


On Sun, 2 Jun 2013 19:28:42 +0200, Mathias.Born at gmx.de wrote:
> 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

Already fixed in current snapshots I think.

Phil


More information about the PyQt mailing list