You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/devel/tutorials/tutorial_tool_qt.rst
+38-33Lines changed: 38 additions & 33 deletions
Original file line number
Diff line number
Diff line change
@@ -26,14 +26,14 @@ that defines a graphical interface showing a text-input
26
26
field that logs text typed by the user via the appropriate
27
27
`log command <../../user/commands/log.html>`_.
28
28
29
-
The ChimeraX user interface is built using `PyQt5`_,
30
-
which is a Python wrapping of the `Qt5`_ C++ windowing toolkit.
31
-
Bundle writers can themselves use `PyQt5`_ to provide
29
+
The ChimeraX user interface is built using `PyQt6`_,
30
+
which is a Python wrapping of the `Qt6`_ C++ windowing toolkit.
31
+
Bundle writers can themselves use `PyQt6`_ to provide
32
32
a graphical interface to their bundle functionality.
33
33
This example shows how to build a simple graphical interface,
34
34
and is not meant to cover all the capabilities of `Qt`_
35
35
in detail (and there are many!). To learn more you should
36
-
explore `PyQt5 tutorials`_
36
+
explore `PyQt6 tutorials`_
37
37
and/or look at the code of other tools that do things
38
38
similar to what you want your tool to do.
39
39
@@ -266,38 +266,43 @@ Interface Construction
266
266
:end-before: def fill_context_menu
267
267
268
268
The :py:meth:`_build_ui` method adds our user interface widgets to the tool window
269
-
and causes the tool window to be shown. `PyQt5`_ is the windowing toolkit used by ChimeraX.
270
-
It is a Python wrapping of the (C++) `Qt5`_ toolkit. This tutorial is in no way meant
271
-
to also be a `PyQt5`_/`Qt5`_ tutorial (since those toolkits are *very* extensive) but
269
+
and causes the tool window to be shown. `PyQt6`_ is the windowing toolkit used by ChimeraX.
270
+
It is a Python wrapping of the (C++) `Qt6`_ toolkit. This tutorial is in no way meant
271
+
to also be a `PyQt6`_/`Qt6`_ tutorial (since those toolkits are *very* extensive) but
272
272
merely shows how to use those toolkits in the context of ChimeraX.
273
273
To gain additional familarity with those toolkits, there are
274
-
`PyQt5 tutorials`_ and
275
-
`Qt5 tutorials <https://zetcode.com/gui/qt5/>`_ available on the web.
274
+
`PyQt6 tutorials`_ and
275
+
`Qt6 tutorials <https://zetcode.com/gui/qt6/>`_ available on the web.
276
+
Note that in ChimeraX, Qt functionality is imported from "Qt" rather than directly from PyQt6.
277
+
"Qt" is a shim module that in turn imports from whatever module is actually providing
278
+
the Python Qt wrapping. This insulates your code from changes in the major Qt version
279
+
number (such as when we went from 5 to 6) and from ChimeraX using an alternate wrapping,
280
+
such as `PySide <https://wiki.qt.io/Qt_for_Python>`_.
276
281
277
-
On line 69 we import the widgets will need for our interface from the `PyQt5`_ toolkit:
282
+
On line 69 we import the widgets will need for our interface from the `PyQt6`_ toolkit:
278
283
279
-
* A text-label widget (`QLabel <https://doc.qt.io/qt-5/qlabel.html>`_)
280
-
* An editable single-line text entry field (`QLineEdit <https://doc.qt.io/qt-5/qlineedit.html>`_)
281
-
* A "metawidget" for laying out the above two widgets side by side (`QHBoxLayout <https://doc.qt.io/qt-5/qhboxlayout.html>`_; "HBox" == "horizontal box")
284
+
* A text-label widget (`QLabel <https://doc.qt.io/qt-6/qlabel.html>`_)
285
+
* An editable single-line text entry field (`QLineEdit <https://doc.qt.io/qt-6/qlineedit.html>`_)
286
+
* A "metawidget" for laying out the above two widgets side by side (`QHBoxLayout <https://doc.qt.io/qt-6/qhboxlayout.html>`_; "HBox" == "horizontal box")
282
287
283
288
Line 70 creates our horizontal layout metawidget, and line 71 creates and adds
284
289
the label we want next to our entry field to it. Note that by default widgets
285
-
added to an `QHBoxLayout <https://doc.qt.io/qt-5/qhboxlayout.html>`_ will be ordered left to right.
290
+
added to an `QHBoxLayout <https://doc.qt.io/qt-6/qhboxlayout.html>`_ will be ordered left to right.
286
291
Line 72 creates our text-entry field and line 77 adds it to out layout.
287
292
288
293
Changes in widgets that the containing interface may care about cause the widget to
289
294
emit what `Qt`_ refers to as a "signal".
290
-
`returnPressed <https://doc.qt.io/qt-5/qlineedit.html#returnPressed>`_ is the signal that
291
-
`QLineEdit <https://doc.qt.io/qt-5/qlineedit.html>`_ emits when the users presses the Return key.
295
+
`returnPressed <https://doc.qt.io/qt-6/qlineedit.html#returnPressed>`_ is the signal that
296
+
`QLineEdit <https://doc.qt.io/qt-6/qlineedit.html>`_ emits when the users presses the Return key.
292
297
A signal's :py:meth:`connect` method is the way to get a particular routine to be called when
293
298
the signal is emitted, which we have done on line 76 to get our :py:meth:`return_pressed`
294
-
method called when the `returnPressed <https://doc.qt.io/qt-5/qlineedit.html#returnPressed>`_
299
+
method called when the `returnPressed <https://doc.qt.io/qt-6/qlineedit.html#returnPressed>`_
295
300
signal is emitted.
296
301
297
-
Lines 86-90 is our handler for the `returnPressed <https://doc.qt.io/qt-5/qlineedit.html#returnPressed>`_
302
+
Lines 86-90 is our handler for the `returnPressed <https://doc.qt.io/qt-6/qlineedit.html#returnPressed>`_
298
303
signal. Some signals also have
299
304
arguments (detailed in each widget's signal documentation), but the
raiseUserError(f'AlphaFold predicted aligned error (PAE) files must be in JSON (*.json) or numpy (*.npy) or pickle (*.pkl) format, {path} unrecognized format')
1230
+
raiseUserError(f'AlphaFold predicted aligned error (PAE) files must be in JSON (*.json) or numpy (*.npy, *.npz) or pickle (*.pkl) format, {path} unrecognized format')
0 commit comments