PyQt6 QFormLayout and uic

Phil Thompson phil at riverbankcomputing.com
Mon Nov 15 09:50:25 GMT 2021


On 14/11/2021 20:14, Timmy Welch wrote:
> Hello,
> I am trying to convert a python app from PyQt5 to PyQt6 and I am using
> the uic module to load the GUI.
> However uic fails loading when I have either the 
> layoutFieldGrowthPolicy or
> rowWrapPolicy fields set on a QFormLayout, attached is an example ui 
> file
> that fails when ran with 'pyuic6 -p' and the output from 'pyuic6 
> --debug
> -p'.
> From my own investigation into the issue it appears that these enums 
> need
> to be added to PyQt6/uic/enum_map.py.
> 
> Any assistance would be appreciated.

Should be fixed in the next snapshot.

Thanks,
Phil
-------------- next part --------------
(venv) timmywelch at Timmys-Mac-mini comictagger % pyuic6 -p comictaggerlib/ui/untitled.ui
An unexpected error occurred.
Check that you are using the latest version of pyuic6 and send an error report
to the PyQt mailing list and include the following information:

- your version of pyuic6 (6.2.1)
- the .ui file that caused this error
- the debug output of pyuic6 (use the --debug flag when calling pyuic6)
zsh: exit 1     pyuic6 -p comictaggerlib/ui/untitled.ui
(venv) timmywelch at Timmys-Mac-mini comictagger % pyuic6 --debug -p comictaggerlib/ui/untitled.ui
PyQt6.uic.uiparser: toplevel widget is QMainWindow
PyQt6.uic.properties: setting property geometry
PyQt6.uic.properties: setting property windowTitle
PyQt6.uic.uiparser: push QMainWindow MainWindow
PyQt6.uic.uiparser: push QWidget centralwidget
PyQt6.uic.properties: setting property geometry
PyQt6.uic.uiparser: push QWidget formLayoutWidget
PyQt6.uic.properties: setting property fieldGrowthPolicy
Traceback (most recent call last):
  File "/Users/timmywelch/build/source/comictagger/venv/lib/python3.10/site-packages/PyQt6/uic/pyuic.py", line 67, in main
    exit_status = preview(args.ui)
  File "/Users/timmywelch/build/source/comictagger/venv/lib/python3.10/site-packages/PyQt6/uic/pyuic.py", line 143, in preview
    ui = loadUi(ui_file)
  File "/Users/timmywelch/build/source/comictagger/venv/lib/python3.10/site-packages/PyQt6/uic/load_ui.py", line 86, in loadUi
    return DynamicUILoader(package).loadUi(uifile, baseinstance)
  File "/Users/timmywelch/build/source/comictagger/venv/lib/python3.10/site-packages/PyQt6/uic/Loader/loader.py", line 62, in loadUi
    return self.parse(filename)
  File "/Users/timmywelch/build/source/comictagger/venv/lib/python3.10/site-packages/PyQt6/uic/uiparser.py", line 1000, in parse
    self._handle_widget(ui_file.widget)
  File "/Users/timmywelch/build/source/comictagger/venv/lib/python3.10/site-packages/PyQt6/uic/uiparser.py", line 828, in _handle_widget
    self.traverseWidgetTree(el)
  File "/Users/timmywelch/build/source/comictagger/venv/lib/python3.10/site-packages/PyQt6/uic/uiparser.py", line 804, in traverseWidgetTree
    handler(self, child)
  File "/Users/timmywelch/build/source/comictagger/venv/lib/python3.10/site-packages/PyQt6/uic/uiparser.py", line 271, in createWidget
    self.traverseWidgetTree(elem)
  File "/Users/timmywelch/build/source/comictagger/venv/lib/python3.10/site-packages/PyQt6/uic/uiparser.py", line 804, in traverseWidgetTree
    handler(self, child)
  File "/Users/timmywelch/build/source/comictagger/venv/lib/python3.10/site-packages/PyQt6/uic/uiparser.py", line 271, in createWidget
    self.traverseWidgetTree(elem)
  File "/Users/timmywelch/build/source/comictagger/venv/lib/python3.10/site-packages/PyQt6/uic/uiparser.py", line 804, in traverseWidgetTree
    handler(self, child)
  File "/Users/timmywelch/build/source/comictagger/venv/lib/python3.10/site-packages/PyQt6/uic/uiparser.py", line 500, in createLayout
    self.stack.push(self.setupObject(classname, parent, elem))
  File "/Users/timmywelch/build/source/comictagger/venv/lib/python3.10/site-packages/PyQt6/uic/uiparser.py", line 228, in setupObject
    self.wprops.setProperties(obj, branch)
  File "/Users/timmywelch/build/source/comictagger/venv/lib/python3.10/site-packages/PyQt6/uic/properties.py", line 430, in setProperties
    prop_value = self.convert(prop, widget)
  File "/Users/timmywelch/build/source/comictagger/venv/lib/python3.10/site-packages/PyQt6/uic/properties.py", line 393, in convert
    return func(prop[0], **args)
  File "/Users/timmywelch/build/source/comictagger/venv/lib/python3.10/site-packages/PyQt6/uic/properties.py", line 141, in _enum
    return self._pyEnumMember(prop.text)
  File "/Users/timmywelch/build/source/comictagger/venv/lib/python3.10/site-packages/PyQt6/uic/properties.py", line 127, in _pyEnumMember
    scope = getattr(scope, tail)
AttributeError: type object 'QFormLayout' has no attribute 'AllNonFixedFieldsGrow'
zsh: exit 1     pyuic6 --debug -p comictaggerlib/ui/untitled.ui
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.ui
Type: application/octet-stream
Size: 1102 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20211115/55bf7113/attachment-0001.obj>


More information about the PyQt mailing list