PyQt6 ui parsing bug (and a solution)
Marijan Smetko
msmetko at msmetko.xyz
Thu Nov 18 20:49:37 GMT 2021
Hello,
I was playing with PyQt6 and I've encountered a bug with uic.
I have attached the untitled.ui file and the main.py file. when running `python3 main.py` it breaks with the following error:
```
Traceback (most recent call last):
File "/home/msmetko/Projects/qt/main.py", line 12, in <module>
window = Ui()
...
...
File "/home/msmetko/Projects/qt/venv/lib/python3.9/site-packages/PyQt6/uic/uiparser.py", line 62, in _parse_alignment
align = getattr(QtCore.Qt, qt_align)
AttributeError: type object 'Qt' has no attribute 'AlignHCenter'
I was running the main.py inside a freshly made venv with these requirements:
```
click==7.1.2
greenlet==1.1.2
msgpack==1.0.2
pynvim==0.4.3
PyQt6==6.2.1
pyqt6-plugins==6.1.0.2.2
PyQt6-Qt6==6.2.1
PyQt6-sip==13.1.0
python-dotenv==0.19.2
qt6-applications==6.1.0.2.2
qt6-tools==6.1.0.1.2
```
I've also found a solution:
```
$ git diff uiparser-old.py uiparser.py
62c62
< align = getattr(QtCore.Qt, qt_align)
---
> align = getattr(QtCore.Qt.AlignmentFlag, qt_align)
```
I had no idea where to put this but I was refered to this mailing list.
Kind regards, and have a nice day,
Marijan Smetko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20211118/996efb70/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: untitled.ui
Type: application/x-designer
Size: 937 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20211118/996efb70/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.py
Type: text/x-python
Size: 279 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20211118/996efb70/attachment.py>
More information about the PyQt
mailing list