<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>On 08/07/2022 16:37, Florian Bruhin wrote:<br>
</p>
<blockquote type="cite"
cite="mid:20220708153749.dolz3bq3h7d22glh@aragog">
<pre class="moz-quote-pre" wrap="">Hey,
On Fri, Jul 08, 2022 at 04:13:53PM +0100, Barry Scott wrote:
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">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.
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
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:
<a class="moz-txt-link-freetext" href="https://doc.qt.io/qt-6/qaction.html#MenuRole-enum">https://doc.qt.io/qt-6/qaction.html#MenuRole-enum</a></pre>
</blockquote>
<p>I have been doing that with success.
</p>
<blockquote type="cite"
cite="mid:20220708153749.dolz3bq3h7d22glh@aragog">
<pre class="moz-quote-pre" wrap="">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:
<a class="moz-txt-link-freetext" href="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_find_enums.py</a>
<a class="moz-txt-link-freetext" href="https://github.com/qutebrowser/qutebrowser/blob/qt6-v2/scripts/dev/rewrite_enums.py">https://github.com/qutebrowser/qutebrowser/blob/qt6-v2/scripts/dev/rewrite_enums.py</a>
with a list of enum mappings here:
<a class="moz-txt-link-freetext" href="https://github.com/qutebrowser/qutebrowser/blob/qt6-v2/scripts/dev/enums.txt">https://github.com/qutebrowser/qutebrowser/blob/qt6-v2/scripts/dev/enums.txt</a></pre>
</blockquote>
<p>Thanks I got your tools running.</p>
<p>But I'm still none the wiser how to fix this:</p>
<p><span style="font-family:monospace"><span
style="color:#000000;background-color:#ffffff;"> def
_addMenu( self, menu, name, handler, enabler=None,
icon_name=None, checker=None, group=None, role=QtWidgets</span><br>
.QAction.MenuRole.NoRole ):
<br>
AttributeError: module 'PyQt6.QtWidgets' has no attribute
'QAction'<br>
<br>
I am using the KDE build of Qt6/PyQt6 for Fedora copr that is
version 6.2.3.</span></p>
<p><span style="font-family:monospace">Is this a problem with this
being an older version?<br>
</span></p>
<p><span style="font-family:monospace">Barry<br>
</span></p>
<br>
</body>
</html>