How to find enum's in PyQt6?
Florian Bruhin
me at the-compiler.org
Fri Jul 8 16:37:49 BST 2022
Hey,
On Fri, Jul 08, 2022 at 04:13:53PM +0100, Barry Scott wrote:
> I've ported Barry's Emacs to PyQt6 and managed to track down all the enums that it uses.
>
> But I'm not finding the enums that SCM Workbench uses.
>
> How do you suggest I can find the enums without asking the list each time.
>
> For example I'm current looking for these symbols from PyQt5 for PyQt6:
>
> QtWidgets.QAction.NoRole
> QtCore.Qt.UserRole
>
> But I am bound to need to know how to port a lot more.
>
> I've used introspection in the past to track down symbols but that is
> not yielding results yet.
In the Qt documentation, you can find the enum type the value belongs
to by looking at the class involved and searching for the value:
https://doc.qt.io/qt-6/qaction.html#MenuRole-enum
Thus, that would be QAction.MenuRole.NoRole.
Or you ask PyQt5:
>>> from PyQt5.QtWidgets import QAction
>>> type(QAction.NoRole)
<class 'PyQt5.QtWidgets.QAction.MenuRole'>
However, why bother doing this manually at all? I'm aware of three
different tools to do this automatically.
Mine:
https://github.com/qutebrowser/qutebrowser/blob/qt6-v2/scripts/dev/rewrite_find_enums.py
https://github.com/qutebrowser/qutebrowser/blob/qt6-v2/scripts/dev/rewrite_enums.py
with a list of enum mappings here:
https://github.com/qutebrowser/qutebrowser/blob/qt6-v2/scripts/dev/enums.txt
Another one by JakobDev:
https://gitlab.com/JakobDev/PyQtEnumConverter
And one posted recently by Kristof Mulier:
https://stackoverflow.com/a/72658216/6178507
Florian
--
me at the-compiler.org | https://www.qutebrowser.org
https://bruhin.software/ | https://github.com/sponsors/The-Compiler/
GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
I love long mails! | https://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20220708/5c7b4d9d/attachment.sig>
More information about the PyQt
mailing list