Qt{5 -> 6}

Some changes are due to deprecations in Qt6 which were outright
removed in PyQt, for instance QRegExp or the x()/y() QMouseEvent
properties. Most of the diff is due to enumeration values now no
longer being available directly in the parent namespace.

This commit is purposefully restricted to the mechanical changes,
no reformatting/… is done to keep the diff easy to validate.
This commit is contained in:
David Nadlinger 2023-09-16 23:52:13 +01:00 committed by Sébastien Bourdeauducq
parent 378d962edb
commit 9fbd6de30c
35 changed files with 359 additions and 357 deletions

View File

@ -15,7 +15,7 @@ ARTIQ and its dependencies are available in the form of Nix packages (for Linux)
ARTIQ is supported by M-Labs and developed openly. Components, features, fixes, improvements, and extensions are often `funded <https://m-labs.hk/experiment-control/funding/>`_ by and developed for the partnering research groups. ARTIQ is supported by M-Labs and developed openly. Components, features, fixes, improvements, and extensions are often `funded <https://m-labs.hk/experiment-control/funding/>`_ by and developed for the partnering research groups.
Core technologies employed include `Python <https://www.python.org/>`_, `Migen <https://github.com/m-labs/migen>`_, `Migen-AXI <https://github.com/peteut/migen-axi>`_, `Rust <https://www.rust-lang.org/>`_, `MiSoC <https://github.com/m-labs/misoc>`_/`VexRiscv <https://github.com/SpinalHDL/VexRiscv>`_, `LLVM <https://llvm.org/>`_/`llvmlite <https://github.com/numba/llvmlite>`_, and `Qt5 <https://www.qt.io/>`_. Core technologies employed include `Python <https://www.python.org/>`_, `Migen <https://github.com/m-labs/migen>`_, `Migen-AXI <https://github.com/peteut/migen-axi>`_, `Rust <https://www.rust-lang.org/>`_, `MiSoC <https://github.com/m-labs/misoc>`_/`VexRiscv <https://github.com/SpinalHDL/VexRiscv>`_, `LLVM <https://llvm.org/>`_/`llvmlite <https://github.com/numba/llvmlite>`_, and `Qt6 <https://www.qt.io/>`_.
| Website: https://m-labs.hk/experiment-control/artiq | Website: https://m-labs.hk/experiment-control/artiq
| (US-hosted mirror: https://m-labs-intl.com/experiment-control/artiq) | (US-hosted mirror: https://m-labs-intl.com/experiment-control/artiq)

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from PyQt5 import QtWidgets, QtCore, QtGui from PyQt6 import QtWidgets, QtCore, QtGui
from artiq.applets.simple import SimpleApplet from artiq.applets.simple import SimpleApplet
from artiq.tools import scale_from_metadata from artiq.tools import scale_from_metadata
from artiq.gui.tools import LayoutWidget from artiq.gui.tools import LayoutWidget
@ -17,7 +17,7 @@ class QCancellableLineEdit(QtWidgets.QLineEdit):
editCancelled = QtCore.pyqtSignal() editCancelled = QtCore.pyqtSignal()
def keyPressEvent(self, event): def keyPressEvent(self, event):
if event.key() == QtCore.Qt.Key_Escape: if event.key() == QtCore.Qt.Key.Key_Escape:
self.editCancelled.emit() self.editCancelled.emit()
else: else:
super().keyPressEvent(event) super().keyPressEvent(event)
@ -44,7 +44,7 @@ class NumberWidget(LayoutWidget):
self.edit_widget = QCancellableLineEdit() self.edit_widget = QCancellableLineEdit()
self.edit_widget.setValidator(QtGui.QDoubleValidator()) self.edit_widget.setValidator(QtGui.QDoubleValidator())
self.edit_widget.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.edit_widget.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight | QtCore.Qt.AlignmentFlag.AlignVCenter)
self.edit_widget.editCancelled.connect(self.cancel_edit) self.edit_widget.editCancelled.connect(self.cancel_edit)
self.edit_widget.returnPressed.connect(self.confirm_edit) self.edit_widget.returnPressed.connect(self.confirm_edit)
self.number_area.addWidget(self.edit_widget) self.number_area.addWidget(self.edit_widget)

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import PyQt5 # make sure pyqtgraph imports Qt5 import PyQt6 # make sure pyqtgraph imports Qt6
import pyqtgraph import pyqtgraph
from artiq.applets.simple import SimpleApplet from artiq.applets.simple import SimpleApplet

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import PyQt5 # make sure pyqtgraph imports Qt5 import PyQt6 # make sure pyqtgraph imports Qt6
from PyQt5.QtCore import QTimer from PyQt6.QtCore import QTimer
import pyqtgraph import pyqtgraph
from artiq.applets.simple import TitleApplet from artiq.applets.simple import TitleApplet

View File

@ -1,8 +1,8 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import numpy as np import numpy as np
import PyQt5 # make sure pyqtgraph imports Qt5 import PyQt6 # make sure pyqtgraph imports Qt6
from PyQt5.QtCore import QTimer from PyQt6.QtCore import QTimer
import pyqtgraph import pyqtgraph
from artiq.applets.simple import TitleApplet from artiq.applets.simple import TitleApplet

View File

@ -1,8 +1,8 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import numpy as np import numpy as np
from PyQt5 import QtWidgets from PyQt6 import QtWidgets
from PyQt5.QtCore import QTimer from PyQt6.QtCore import QTimer
import pyqtgraph import pyqtgraph
from artiq.applets.simple import SimpleApplet from artiq.applets.simple import SimpleApplet

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from PyQt5 import QtWidgets from PyQt6 import QtWidgets
from artiq.applets.simple import SimpleApplet from artiq.applets.simple import SimpleApplet

View File

@ -273,7 +273,7 @@ class SimpleApplet:
# HACK: if the window has a frame, there will be garbage # HACK: if the window has a frame, there will be garbage
# (usually white) displayed at its right and bottom borders # (usually white) displayed at its right and bottom borders
# after it is embedded. # after it is embedded.
self.main_widget.setWindowFlags(QtCore.Qt.FramelessWindowHint) self.main_widget.setWindowFlags(QtCore.Qt.WindowType.FramelessWindowHint)
self.main_widget.show() self.main_widget.show()
win_id = int(self.main_widget.winId()) win_id = int(self.main_widget.winId())
self.loop.run_until_complete(self.ipc.embed(win_id)) self.loop.run_until_complete(self.ipc.embed(win_id))

View File

@ -1,7 +1,7 @@
import logging import logging
import asyncio import asyncio
from PyQt5 import QtCore, QtWidgets from PyQt6 import QtCore, QtGui, QtWidgets
from sipyco.pc_rpc import AsyncioClient as RPCClient from sipyco.pc_rpc import AsyncioClient as RPCClient
@ -62,8 +62,8 @@ class DatasetsDock(QtWidgets.QDockWidget):
def __init__(self, dataset_sub, dataset_ctl): def __init__(self, dataset_sub, dataset_ctl):
QtWidgets.QDockWidget.__init__(self, "Datasets") QtWidgets.QDockWidget.__init__(self, "Datasets")
self.setObjectName("Datasets") self.setObjectName("Datasets")
self.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable | self.setFeatures(QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetMovable |
QtWidgets.QDockWidget.DockWidgetFloatable) QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetFloatable)
grid = LayoutWidget() grid = LayoutWidget()
self.setWidget(grid) self.setWidget(grid)
@ -74,9 +74,9 @@ class DatasetsDock(QtWidgets.QDockWidget):
grid.addWidget(self.search, 0, 0) grid.addWidget(self.search, 0, 0)
self.table = QtWidgets.QTreeView() self.table = QtWidgets.QTreeView()
self.table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) self.table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectionBehavior.SelectRows)
self.table.setSelectionMode( self.table.setSelectionMode(
QtWidgets.QAbstractItemView.SingleSelection) QtWidgets.QAbstractItemView.SelectionMode.SingleSelection)
grid.addWidget(self.table, 1, 0) grid.addWidget(self.table, 1, 0)
metadata_grid = LayoutWidget() metadata_grid = LayoutWidget()
@ -85,13 +85,13 @@ class DatasetsDock(QtWidgets.QDockWidget):
"rid start_time".split()): "rid start_time".split()):
metadata_grid.addWidget(QtWidgets.QLabel(label), i, 0) metadata_grid.addWidget(QtWidgets.QLabel(label), i, 0)
v = QtWidgets.QLabel() v = QtWidgets.QLabel()
v.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse) v.setTextInteractionFlags(QtCore.Qt.TextInteractionFlag.TextSelectableByMouse)
metadata_grid.addWidget(v, i, 1) metadata_grid.addWidget(v, i, 1)
self.metadata[label] = v self.metadata[label] = v
grid.addWidget(metadata_grid, 2, 0) grid.addWidget(metadata_grid, 2, 0)
self.table.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.table.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.ActionsContextMenu)
upload_action = QtWidgets.QAction("Upload dataset to master", upload_action = QtGui.QAction("Upload dataset to master",
self.table) self.table)
upload_action.triggered.connect(self.upload_clicked) upload_action.triggered.connect(self.upload_clicked)
self.table.addAction(upload_action) self.table.addAction(upload_action)

View File

@ -4,7 +4,7 @@ import os
from functools import partial from functools import partial
from collections import OrderedDict from collections import OrderedDict
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt6 import QtCore, QtGui, QtWidgets
import h5py import h5py
from sipyco import pyon from sipyco import pyon
@ -33,13 +33,13 @@ class _ArgumentEditor(EntryTreeWidget):
recompute_arguments = QtWidgets.QPushButton("Recompute all arguments") recompute_arguments = QtWidgets.QPushButton("Recompute all arguments")
recompute_arguments.setIcon( recompute_arguments.setIcon(
QtWidgets.QApplication.style().standardIcon( QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_BrowserReload)) QtWidgets.QStyle.StandardPixmap.SP_BrowserReload))
recompute_arguments.clicked.connect(self._recompute_arguments_clicked) recompute_arguments.clicked.connect(self._recompute_arguments_clicked)
load = QtWidgets.QPushButton("Set arguments from HDF5") load = QtWidgets.QPushButton("Set arguments from HDF5")
load.setToolTip("Set arguments from currently selected HDF5 file") load.setToolTip("Set arguments from currently selected HDF5 file")
load.setIcon(QtWidgets.QApplication.style().standardIcon( load.setIcon(QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_DialogApplyButton)) QtWidgets.QStyle.StandardPixmap.SP_DialogApplyButton))
load.clicked.connect(self._load_clicked) load.clicked.connect(self._load_clicked)
buttons = LayoutWidget() buttons = LayoutWidget()
@ -86,7 +86,7 @@ class _ExperimentDock(QtWidgets.QMdiSubWindow):
self.resize(100*qfm.averageCharWidth(), 30*qfm.lineSpacing()) self.resize(100*qfm.averageCharWidth(), 30*qfm.lineSpacing())
self.setWindowTitle(expurl) self.setWindowTitle(expurl)
self.setWindowIcon(QtWidgets.QApplication.style().standardIcon( self.setWindowIcon(QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_FileDialogContentsView)) QtWidgets.QStyle.StandardPixmap.SP_FileDialogContentsView))
self.setAcceptDrops(True) self.setAcceptDrops(True)
self.layout = QtWidgets.QGridLayout() self.layout = QtWidgets.QGridLayout()
@ -126,22 +126,22 @@ class _ExperimentDock(QtWidgets.QMdiSubWindow):
run = QtWidgets.QPushButton("Analyze") run = QtWidgets.QPushButton("Analyze")
run.setIcon(QtWidgets.QApplication.style().standardIcon( run.setIcon(QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_DialogOkButton)) QtWidgets.QStyle.StandardPixmap.SP_DialogOkButton))
run.setToolTip("Run analysis stage (Ctrl+Return)") run.setToolTip("Run analysis stage (Ctrl+Return)")
run.setShortcut("CTRL+RETURN") run.setShortcut("CTRL+RETURN")
run.setSizePolicy(QtWidgets.QSizePolicy.Expanding, run.setSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding,
QtWidgets.QSizePolicy.Expanding) QtWidgets.QSizePolicy.Policy.Expanding)
self.layout.addWidget(run, 2, 4) self.layout.addWidget(run, 2, 4)
run.clicked.connect(self._run_clicked) run.clicked.connect(self._run_clicked)
self._run = run self._run = run
terminate = QtWidgets.QPushButton("Terminate") terminate = QtWidgets.QPushButton("Terminate")
terminate.setIcon(QtWidgets.QApplication.style().standardIcon( terminate.setIcon(QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_DialogCancelButton)) QtWidgets.QStyle.StandardPixmap.SP_DialogCancelButton))
terminate.setToolTip("Terminate analysis (Ctrl+Backspace)") terminate.setToolTip("Terminate analysis (Ctrl+Backspace)")
terminate.setShortcut("CTRL+BACKSPACE") terminate.setShortcut("CTRL+BACKSPACE")
terminate.setSizePolicy(QtWidgets.QSizePolicy.Expanding, terminate.setSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding,
QtWidgets.QSizePolicy.Expanding) QtWidgets.QSizePolicy.Policy.Expanding)
self.layout.addWidget(terminate, 3, 4) self.layout.addWidget(terminate, 3, 4)
terminate.clicked.connect(self._terminate_clicked) terminate.clicked.connect(self._terminate_clicked)
terminate.setEnabled(False) terminate.setEnabled(False)
@ -316,7 +316,7 @@ class ExperimentsArea(QtWidgets.QMdiArea):
asyncio.ensure_future(sub.load_hdf5_task(path)) asyncio.ensure_future(sub.load_hdf5_task(path))
def mousePressEvent(self, ev): def mousePressEvent(self, ev):
if ev.button() == QtCore.Qt.LeftButton: if ev.button() == QtCore.Qt.MouseButton.LeftButton:
self.select_experiment() self.select_experiment()
def paintEvent(self, event): def paintEvent(self, event):
@ -406,7 +406,7 @@ class ExperimentsArea(QtWidgets.QMdiArea):
exc_info=True) exc_info=True)
dock = _ExperimentDock(self, expurl, {}) dock = _ExperimentDock(self, expurl, {})
asyncio.ensure_future(dock._recompute_arguments()) asyncio.ensure_future(dock._recompute_arguments())
dock.setAttribute(QtCore.Qt.WA_DeleteOnClose) dock.setAttribute(QtCore.Qt.WidgetAttribute.WA_DeleteOnClose)
self.addSubWindow(dock) self.addSubWindow(dock)
dock.show() dock.show()
dock.sigClosed.connect(partial(self.on_dock_closed, dock)) dock.sigClosed.connect(partial(self.on_dock_closed, dock))

View File

@ -3,7 +3,7 @@ import os
from datetime import datetime from datetime import datetime
import h5py import h5py
from PyQt5 import QtCore, QtWidgets, QtGui from PyQt6 import QtCore, QtWidgets, QtGui
from sipyco import pyon from sipyco import pyon
@ -69,15 +69,15 @@ class ZoomIconView(QtWidgets.QListView):
def __init__(self): def __init__(self):
QtWidgets.QListView.__init__(self) QtWidgets.QListView.__init__(self)
self._char_width = QtGui.QFontMetrics(self.font()).averageCharWidth() self._char_width = QtGui.QFontMetrics(self.font()).averageCharWidth()
self.setViewMode(self.IconMode) self.setViewMode(self.ViewMode.IconMode)
w = self._char_width*self.default_size w = self._char_width*self.default_size
self.setIconSize(QtCore.QSize(w, int(w*self.aspect))) self.setIconSize(QtCore.QSize(w, int(w*self.aspect)))
self.setFlow(self.LeftToRight) self.setFlow(self.Flow.LeftToRight)
self.setResizeMode(self.Adjust) self.setResizeMode(self.ResizeMode.Adjust)
self.setWrapping(True) self.setWrapping(True)
def wheelEvent(self, ev): def wheelEvent(self, ev):
if ev.modifiers() & QtCore.Qt.ControlModifier: if ev.modifiers() & QtCore.Qt.KeyboardModifier.ControlModifier:
a = self._char_width*self.min_size a = self._char_width*self.min_size
b = self._char_width*self.max_size b = self._char_width*self.max_size
w = self.iconSize().width()*self.zoom_step**( w = self.iconSize().width()*self.zoom_step**(
@ -88,16 +88,16 @@ class ZoomIconView(QtWidgets.QListView):
QtWidgets.QListView.wheelEvent(self, ev) QtWidgets.QListView.wheelEvent(self, ev)
class Hdf5FileSystemModel(QtWidgets.QFileSystemModel): class Hdf5FileSystemModel(QtGui.QFileSystemModel):
def __init__(self): def __init__(self):
QtWidgets.QFileSystemModel.__init__(self) QtGui.QFileSystemModel.__init__(self)
self.setFilter(QtCore.QDir.Drives | QtCore.QDir.NoDotAndDotDot | self.setFilter(QtCore.QDir.Filter.Drives | QtCore.QDir.Filter.NoDotAndDotDot |
QtCore.QDir.AllDirs | QtCore.QDir.Files) QtCore.QDir.Filter.AllDirs | QtCore.QDir.Filter.Files)
self.setNameFilterDisables(False) self.setNameFilterDisables(False)
self.setIconProvider(ThumbnailIconProvider()) self.setIconProvider(ThumbnailIconProvider())
def data(self, idx, role): def data(self, idx, role):
if role == QtCore.Qt.ToolTipRole: if role == QtCore.Qt.ItemDataRole.ToolTipRole:
info = self.fileInfo(idx) info = self.fileInfo(idx)
h5 = open_h5(info) h5 = open_h5(info)
if h5 is not None: if h5 is not None:
@ -114,7 +114,7 @@ class Hdf5FileSystemModel(QtWidgets.QFileSystemModel):
except: except:
logger.warning("unable to read metadata from %s", logger.warning("unable to read metadata from %s",
info.filePath(), exc_info=True) info.filePath(), exc_info=True)
return QtWidgets.QFileSystemModel.data(self, idx, role) return QtGui.QFileSystemModel.data(self, idx, role)
class FilesDock(QtWidgets.QDockWidget): class FilesDock(QtWidgets.QDockWidget):
@ -125,7 +125,7 @@ class FilesDock(QtWidgets.QDockWidget):
def __init__(self, datasets, browse_root=""): def __init__(self, datasets, browse_root=""):
QtWidgets.QDockWidget.__init__(self, "Files") QtWidgets.QDockWidget.__init__(self, "Files")
self.setObjectName("Files") self.setObjectName("Files")
self.setFeatures(self.DockWidgetMovable | self.DockWidgetFloatable) self.setFeatures(self.DockWidgetFeature.DockWidgetMovable | self.DockWidgetFeature.DockWidgetFloatable)
self.splitter = QtWidgets.QSplitter() self.splitter = QtWidgets.QSplitter()
self.setWidget(self.splitter) self.setWidget(self.splitter)
@ -147,8 +147,8 @@ class FilesDock(QtWidgets.QDockWidget):
self.rt.setRootIndex(rt_model.mapFromSource( self.rt.setRootIndex(rt_model.mapFromSource(
self.model.setRootPath(browse_root))) self.model.setRootPath(browse_root)))
self.rt.setHeaderHidden(True) self.rt.setHeaderHidden(True)
self.rt.setSelectionBehavior(self.rt.SelectRows) self.rt.setSelectionBehavior(self.rt.SelectionBehavior.SelectRows)
self.rt.setSelectionMode(self.rt.SingleSelection) self.rt.setSelectionMode(self.rt.SelectionMode.SingleSelection)
self.rt.selectionModel().currentChanged.connect( self.rt.selectionModel().currentChanged.connect(
self.tree_current_changed) self.tree_current_changed)
self.rt.setRootIsDecorated(False) self.rt.setRootIsDecorated(False)
@ -252,7 +252,7 @@ class FilesDock(QtWidgets.QDockWidget):
100, 100,
lambda: self.rt.scrollTo( lambda: self.rt.scrollTo(
self.rt.model().mapFromSource(self.model.index(path)), self.rt.model().mapFromSource(self.model.index(path)),
self.rt.PositionAtCenter) self.rt.ScrollHint.PositionAtCenter)
) )
self.model.directoryLoaded.connect(scroll_when_loaded) self.model.directoryLoaded.connect(scroll_when_loaded)
idx = self.rt.model().mapFromSource(idx) idx = self.rt.model().mapFromSource(idx)

View File

@ -1,7 +1,7 @@
import asyncio import asyncio
import logging import logging
from PyQt5 import QtCore, QtWidgets from PyQt6 import QtCore, QtGui, QtWidgets
from artiq.gui import applets from artiq.gui import applets
@ -13,58 +13,58 @@ class AppletsCCBDock(applets.AppletsDock):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
applets.AppletsDock.__init__(self, *args, **kwargs) applets.AppletsDock.__init__(self, *args, **kwargs)
sep = QtWidgets.QAction(self.table) sep = QtGui.QAction(self.table)
sep.setSeparator(True) sep.setSeparator(True)
self.table.addAction(sep) self.table.addAction(sep)
ccbp_group_menu = QtWidgets.QMenu() ccbp_group_menu = QtWidgets.QMenu()
actiongroup = QtWidgets.QActionGroup(self.table) actiongroup = QtGui.QActionGroup(self.table)
actiongroup.setExclusive(True) actiongroup.setExclusive(True)
self.ccbp_group_none = QtWidgets.QAction("No policy", self.table) self.ccbp_group_none = QtGui.QAction("No policy", self.table)
self.ccbp_group_none.setCheckable(True) self.ccbp_group_none.setCheckable(True)
self.ccbp_group_none.triggered.connect(lambda: self.set_ccbp("")) self.ccbp_group_none.triggered.connect(lambda: self.set_ccbp(""))
ccbp_group_menu.addAction(self.ccbp_group_none) ccbp_group_menu.addAction(self.ccbp_group_none)
actiongroup.addAction(self.ccbp_group_none) actiongroup.addAction(self.ccbp_group_none)
self.ccbp_group_ignore = QtWidgets.QAction("Ignore requests", self.table) self.ccbp_group_ignore = QtGui.QAction("Ignore requests", self.table)
self.ccbp_group_ignore.setCheckable(True) self.ccbp_group_ignore.setCheckable(True)
self.ccbp_group_ignore.triggered.connect(lambda: self.set_ccbp("ignore")) self.ccbp_group_ignore.triggered.connect(lambda: self.set_ccbp("ignore"))
ccbp_group_menu.addAction(self.ccbp_group_ignore) ccbp_group_menu.addAction(self.ccbp_group_ignore)
actiongroup.addAction(self.ccbp_group_ignore) actiongroup.addAction(self.ccbp_group_ignore)
self.ccbp_group_create = QtWidgets.QAction("Create applets", self.table) self.ccbp_group_create = QtGui.QAction("Create applets", self.table)
self.ccbp_group_create.setCheckable(True) self.ccbp_group_create.setCheckable(True)
self.ccbp_group_create.triggered.connect(lambda: self.set_ccbp("create")) self.ccbp_group_create.triggered.connect(lambda: self.set_ccbp("create"))
ccbp_group_menu.addAction(self.ccbp_group_create) ccbp_group_menu.addAction(self.ccbp_group_create)
actiongroup.addAction(self.ccbp_group_create) actiongroup.addAction(self.ccbp_group_create)
self.ccbp_group_enable = QtWidgets.QAction("Create and enable/disable applets", self.ccbp_group_enable = QtGui.QAction("Create and enable/disable applets",
self.table) self.table)
self.ccbp_group_enable.setCheckable(True) self.ccbp_group_enable.setCheckable(True)
self.ccbp_group_enable.triggered.connect(lambda: self.set_ccbp("enable")) self.ccbp_group_enable.triggered.connect(lambda: self.set_ccbp("enable"))
ccbp_group_menu.addAction(self.ccbp_group_enable) ccbp_group_menu.addAction(self.ccbp_group_enable)
actiongroup.addAction(self.ccbp_group_enable) actiongroup.addAction(self.ccbp_group_enable)
self.ccbp_group_action = QtWidgets.QAction("Group CCB policy", self.table) self.ccbp_group_action = QtGui.QAction("Group CCB policy", self.table)
self.ccbp_group_action.setMenu(ccbp_group_menu) self.ccbp_group_action.setMenu(ccbp_group_menu)
self.table.addAction(self.ccbp_group_action) self.table.addAction(self.ccbp_group_action)
self.table.itemSelectionChanged.connect(self.update_group_ccbp_menu) self.table.itemSelectionChanged.connect(self.update_group_ccbp_menu)
self.update_group_ccbp_menu() self.update_group_ccbp_menu()
ccbp_global_menu = QtWidgets.QMenu() ccbp_global_menu = QtWidgets.QMenu()
actiongroup = QtWidgets.QActionGroup(self.table) actiongroup = QtGui.QActionGroup(self.table)
actiongroup.setExclusive(True) actiongroup.setExclusive(True)
self.ccbp_global_ignore = QtWidgets.QAction("Ignore requests", self.table) self.ccbp_global_ignore = QtGui.QAction("Ignore requests", self.table)
self.ccbp_global_ignore.setCheckable(True) self.ccbp_global_ignore.setCheckable(True)
ccbp_global_menu.addAction(self.ccbp_global_ignore) ccbp_global_menu.addAction(self.ccbp_global_ignore)
actiongroup.addAction(self.ccbp_global_ignore) actiongroup.addAction(self.ccbp_global_ignore)
self.ccbp_global_create = QtWidgets.QAction("Create applets", self.table) self.ccbp_global_create = QtGui.QAction("Create applets", self.table)
self.ccbp_global_create.setCheckable(True) self.ccbp_global_create.setCheckable(True)
self.ccbp_global_create.setChecked(True) self.ccbp_global_create.setChecked(True)
ccbp_global_menu.addAction(self.ccbp_global_create) ccbp_global_menu.addAction(self.ccbp_global_create)
actiongroup.addAction(self.ccbp_global_create) actiongroup.addAction(self.ccbp_global_create)
self.ccbp_global_enable = QtWidgets.QAction("Create and enable/disable applets", self.ccbp_global_enable = QtGui.QAction("Create and enable/disable applets",
self.table) self.table)
self.ccbp_global_enable.setCheckable(True) self.ccbp_global_enable.setCheckable(True)
ccbp_global_menu.addAction(self.ccbp_global_enable) ccbp_global_menu.addAction(self.ccbp_global_enable)
actiongroup.addAction(self.ccbp_global_enable) actiongroup.addAction(self.ccbp_global_enable)
ccbp_global_action = QtWidgets.QAction("Global CCB policy", self.table) ccbp_global_action = QtGui.QAction("Global CCB policy", self.table)
ccbp_global_action.setMenu(ccbp_global_menu) ccbp_global_action.setMenu(ccbp_global_menu)
self.table.addAction(ccbp_global_action) self.table.addAction(ccbp_global_action)
@ -196,7 +196,7 @@ class AppletsCCBDock(applets.AppletsDock):
logger.debug("Applet %s already exists and no update required", name) logger.debug("Applet %s already exists and no update required", name)
if ccbp == "enable": if ccbp == "enable":
applet.setCheckState(0, QtCore.Qt.Checked) applet.setCheckState(0, QtCore.Qt.CheckState.Checked)
def ccb_disable_applet(self, name, group=None): def ccb_disable_applet(self, name, group=None):
"""Disables an applet. """Disables an applet.
@ -216,7 +216,7 @@ class AppletsCCBDock(applets.AppletsDock):
return return
parent, applet = self.locate_applet(name, group, False) parent, applet = self.locate_applet(name, group, False)
if applet is not None: if applet is not None:
applet.setCheckState(0, QtCore.Qt.Unchecked) applet.setCheckState(0, QtCore.Qt.CheckState.Unchecked)
def ccb_disable_applet_group(self, group): def ccb_disable_applet_group(self, group):
"""Disables all the applets in a group. """Disables all the applets in a group.
@ -246,7 +246,7 @@ class AppletsCCBDock(applets.AppletsDock):
return return
else: else:
wi = nwi wi = nwi
wi.setCheckState(0, QtCore.Qt.Unchecked) wi.setCheckState(0, QtCore.Qt.CheckState.Unchecked)
def ccb_notify(self, message): def ccb_notify(self, message):
try: try:

View File

@ -2,7 +2,7 @@ import asyncio
import logging import logging
import numpy as np import numpy as np
from PyQt5 import QtCore, QtWidgets from PyQt6 import QtCore, QtGui, QtWidgets
from sipyco import pyon from sipyco import pyon
from artiq.tools import scale_from_metadata, short_format, exc_to_warning from artiq.tools import scale_from_metadata, short_format, exc_to_warning
@ -63,11 +63,11 @@ class CreateEditDialog(QtWidgets.QDialog):
self.cancel = QtWidgets.QPushButton('&Cancel') self.cancel = QtWidgets.QPushButton('&Cancel')
self.buttons = QtWidgets.QDialogButtonBox(self) self.buttons = QtWidgets.QDialogButtonBox(self)
self.buttons.addButton( self.buttons.addButton(
self.ok, QtWidgets.QDialogButtonBox.AcceptRole) self.ok, QtWidgets.QDialogButtonBox.ButtonRole.AcceptRole)
self.buttons.addButton( self.buttons.addButton(
self.cancel, QtWidgets.QDialogButtonBox.RejectRole) self.cancel, QtWidgets.QDialogButtonBox.ButtonRole.RejectRole)
grid.setRowStretch(6, 1) grid.setRowStretch(6, 1)
grid.addWidget(self.buttons, 7, 0, 1, 3, alignment=QtCore.Qt.AlignHCenter) grid.addWidget(self.buttons, 7, 0, 1, 3, alignment=QtCore.Qt.AlignmentFlag.AlignHCenter)
self.buttons.accepted.connect(self.accept) self.buttons.accepted.connect(self.accept)
self.buttons.rejected.connect(self.reject) self.buttons.rejected.connect(self.reject)
@ -125,7 +125,7 @@ class CreateEditDialog(QtWidgets.QDialog):
pyon.encode(result) pyon.encode(result)
except: except:
pixmap = self.style().standardPixmap( pixmap = self.style().standardPixmap(
QtWidgets.QStyle.SP_MessageBoxWarning) QtWidgets.QStyle.StandardPixmap.SP_MessageBoxWarning)
self.data_type.setPixmap(pixmap) self.data_type.setPixmap(pixmap)
self.ok.setEnabled(False) self.ok.setEnabled(False)
else: else:
@ -181,8 +181,8 @@ class DatasetsDock(QtWidgets.QDockWidget):
def __init__(self, dataset_sub, dataset_ctl): def __init__(self, dataset_sub, dataset_ctl):
QtWidgets.QDockWidget.__init__(self, "Datasets") QtWidgets.QDockWidget.__init__(self, "Datasets")
self.setObjectName("Datasets") self.setObjectName("Datasets")
self.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable | self.setFeatures(QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetMovable |
QtWidgets.QDockWidget.DockWidgetFloatable) QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetFloatable)
self.dataset_ctl = dataset_ctl self.dataset_ctl = dataset_ctl
grid = LayoutWidget() grid = LayoutWidget()
@ -194,27 +194,27 @@ class DatasetsDock(QtWidgets.QDockWidget):
grid.addWidget(self.search, 0, 0) grid.addWidget(self.search, 0, 0)
self.table = QtWidgets.QTreeView() self.table = QtWidgets.QTreeView()
self.table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) self.table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectionBehavior.SelectRows)
self.table.setSelectionMode( self.table.setSelectionMode(
QtWidgets.QAbstractItemView.SingleSelection) QtWidgets.QAbstractItemView.SelectionMode.SingleSelection)
grid.addWidget(self.table, 1, 0) grid.addWidget(self.table, 1, 0)
self.table.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.table.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.ActionsContextMenu)
create_action = QtWidgets.QAction("New dataset", self.table) create_action = QtGui.QAction("New dataset", self.table)
create_action.triggered.connect(self.create_clicked) create_action.triggered.connect(self.create_clicked)
create_action.setShortcut("CTRL+N") create_action.setShortcut("CTRL+N")
create_action.setShortcutContext(QtCore.Qt.WidgetShortcut) create_action.setShortcutContext(QtCore.Qt.ShortcutContext.WidgetShortcut)
self.table.addAction(create_action) self.table.addAction(create_action)
edit_action = QtWidgets.QAction("Edit dataset", self.table) edit_action = QtGui.QAction("Edit dataset", self.table)
edit_action.triggered.connect(self.edit_clicked) edit_action.triggered.connect(self.edit_clicked)
edit_action.setShortcut("RETURN") edit_action.setShortcut("RETURN")
edit_action.setShortcutContext(QtCore.Qt.WidgetShortcut) edit_action.setShortcutContext(QtCore.Qt.ShortcutContext.WidgetShortcut)
self.table.doubleClicked.connect(self.edit_clicked) self.table.doubleClicked.connect(self.edit_clicked)
self.table.addAction(edit_action) self.table.addAction(edit_action)
delete_action = QtWidgets.QAction("Delete dataset", self.table) delete_action = QtGui.QAction("Delete dataset", self.table)
delete_action.triggered.connect(self.delete_clicked) delete_action.triggered.connect(self.delete_clicked)
delete_action.setShortcut("DELETE") delete_action.setShortcut("DELETE")
delete_action.setShortcutContext(QtCore.Qt.WidgetShortcut) delete_action.setShortcutContext(QtCore.Qt.ShortcutContext.WidgetShortcut)
self.table.addAction(delete_action) self.table.addAction(delete_action)
self.table_model = Model(dict()) self.table_model = Model(dict())

View File

@ -4,7 +4,7 @@ import os
from functools import partial from functools import partial
from collections import OrderedDict from collections import OrderedDict
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt6 import QtCore, QtGui, QtWidgets
import h5py import h5py
from sipyco import pyon from sipyco import pyon
@ -44,12 +44,12 @@ class _ArgumentEditor(EntryTreeWidget):
recompute_arguments = QtWidgets.QPushButton("Recompute all arguments") recompute_arguments = QtWidgets.QPushButton("Recompute all arguments")
recompute_arguments.setIcon( recompute_arguments.setIcon(
QtWidgets.QApplication.style().standardIcon( QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_BrowserReload)) QtWidgets.QStyle.StandardPixmap.SP_BrowserReload))
recompute_arguments.clicked.connect(dock._recompute_arguments_clicked) recompute_arguments.clicked.connect(dock._recompute_arguments_clicked)
load_hdf5 = QtWidgets.QPushButton("Load HDF5") load_hdf5 = QtWidgets.QPushButton("Load HDF5")
load_hdf5.setIcon(QtWidgets.QApplication.style().standardIcon( load_hdf5.setIcon(QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_DialogOpenButton)) QtWidgets.QStyle.StandardPixmap.SP_DialogOpenButton))
load_hdf5.clicked.connect(dock._load_hdf5_clicked) load_hdf5.clicked.connect(dock._load_hdf5_clicked)
buttons = LayoutWidget() buttons = LayoutWidget()
@ -101,7 +101,7 @@ class _ExperimentDock(QtWidgets.QMdiSubWindow):
self.resize(100 * qfm.averageCharWidth(), 30 * qfm.lineSpacing()) self.resize(100 * qfm.averageCharWidth(), 30 * qfm.lineSpacing())
self.setWindowTitle(expurl) self.setWindowTitle(expurl)
self.setWindowIcon(QtWidgets.QApplication.style().standardIcon( self.setWindowIcon(QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_FileDialogContentsView)) QtWidgets.QStyle.StandardPixmap.SP_FileDialogContentsView))
self.layout = QtWidgets.QGridLayout() self.layout = QtWidgets.QGridLayout()
top_widget = QtWidgets.QWidget() top_widget = QtWidgets.QWidget()
@ -237,21 +237,21 @@ class _ExperimentDock(QtWidgets.QMdiSubWindow):
submit = QtWidgets.QPushButton("Submit") submit = QtWidgets.QPushButton("Submit")
submit.setIcon(QtWidgets.QApplication.style().standardIcon( submit.setIcon(QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_DialogOkButton)) QtWidgets.QStyle.StandardPixmap.SP_DialogOkButton))
submit.setToolTip("Schedule the experiment (Ctrl+Return)") submit.setToolTip("Schedule the experiment (Ctrl+Return)")
submit.setShortcut("CTRL+RETURN") submit.setShortcut("CTRL+RETURN")
submit.setSizePolicy(QtWidgets.QSizePolicy.Expanding, submit.setSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding,
QtWidgets.QSizePolicy.Expanding) QtWidgets.QSizePolicy.Policy.Expanding)
self.layout.addWidget(submit, 1, 4, 2, 1) self.layout.addWidget(submit, 1, 4, 2, 1)
submit.clicked.connect(self.submit_clicked) submit.clicked.connect(self.submit_clicked)
reqterm = QtWidgets.QPushButton("Terminate instances") reqterm = QtWidgets.QPushButton("Terminate instances")
reqterm.setIcon(QtWidgets.QApplication.style().standardIcon( reqterm.setIcon(QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_DialogCancelButton)) QtWidgets.QStyle.StandardPixmap.SP_DialogCancelButton))
reqterm.setToolTip("Request termination of instances (Ctrl+Backspace)") reqterm.setToolTip("Request termination of instances (Ctrl+Backspace)")
reqterm.setShortcut("CTRL+BACKSPACE") reqterm.setShortcut("CTRL+BACKSPACE")
reqterm.setSizePolicy(QtWidgets.QSizePolicy.Expanding, reqterm.setSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding,
QtWidgets.QSizePolicy.Expanding) QtWidgets.QSizePolicy.Policy.Expanding)
self.layout.addWidget(reqterm, 3, 4) self.layout.addWidget(reqterm, 3, 4)
reqterm.clicked.connect(self.reqterm_clicked) reqterm.clicked.connect(self.reqterm_clicked)
@ -306,7 +306,7 @@ class _ExperimentDock(QtWidgets.QMdiSubWindow):
def contextMenuEvent(self, event): def contextMenuEvent(self, event):
menu = QtWidgets.QMenu(self) menu = QtWidgets.QMenu(self)
reset_sched = menu.addAction("Reset scheduler settings") reset_sched = menu.addAction("Reset scheduler settings")
action = menu.exec_(self.mapToGlobal(event.pos())) action = menu.exec(self.mapToGlobal(event.pos()))
if action == reset_sched: if action == reset_sched:
asyncio.ensure_future(self._recompute_sched_options_task()) asyncio.ensure_future(self._recompute_sched_options_task())
@ -423,7 +423,7 @@ class _QuickOpenDialog(QtWidgets.QDialog):
QtWidgets.QDialog.done(self, r) QtWidgets.QDialog.done(self, r)
def _open_experiment(self, exp_name, modifiers): def _open_experiment(self, exp_name, modifiers):
if modifiers & QtCore.Qt.ControlModifier: if modifiers & QtCore.Qt.KeyboardModifier.ControlModifier:
try: try:
self.manager.submit(exp_name) self.manager.submit(exp_name)
except: except:
@ -467,10 +467,10 @@ class ExperimentManager:
self.open_experiments = dict() self.open_experiments = dict()
self.is_quick_open_shown = False self.is_quick_open_shown = False
quick_open_shortcut = QtWidgets.QShortcut( quick_open_shortcut = QtGui.QShortcut(
QtCore.Qt.CTRL + QtCore.Qt.Key_P, QtGui.QKeySequence("Ctrl+P"),
main_window) main_window)
quick_open_shortcut.setContext(QtCore.Qt.ApplicationShortcut) quick_open_shortcut.setContext(QtCore.Qt.ShortcutContext.ApplicationShortcut)
quick_open_shortcut.activated.connect(self.show_quick_open) quick_open_shortcut.activated.connect(self.show_quick_open)
def set_dataset_model(self, model): def set_dataset_model(self, model):
@ -589,7 +589,7 @@ class ExperimentManager:
del self.submission_arguments[expurl] del self.submission_arguments[expurl]
dock = _ExperimentDock(self, expurl) dock = _ExperimentDock(self, expurl)
self.open_experiments[expurl] = dock self.open_experiments[expurl] = dock
dock.setAttribute(QtCore.Qt.WA_DeleteOnClose) dock.setAttribute(QtCore.Qt.WidgetAttribute.WA_DeleteOnClose)
self.main_window.centralWidget().addSubWindow(dock) self.main_window.centralWidget().addSubWindow(dock)
dock.show() dock.show()
dock.sigClosed.connect(partial(self.on_dock_closed, expurl)) dock.sigClosed.connect(partial(self.on_dock_closed, expurl))

View File

@ -3,7 +3,7 @@ import logging
import re import re
from functools import partial from functools import partial
from PyQt5 import QtCore, QtWidgets from PyQt6 import QtCore, QtGui, QtWidgets
from artiq.gui.tools import LayoutWidget from artiq.gui.tools import LayoutWidget
from artiq.gui.models import DictSyncTreeSepModel from artiq.gui.models import DictSyncTreeSepModel
@ -37,7 +37,8 @@ class _OpenFileDialog(QtWidgets.QDialog):
self.file_list.doubleClicked.connect(self.accept) self.file_list.doubleClicked.connect(self.accept)
buttons = QtWidgets.QDialogButtonBox( buttons = QtWidgets.QDialogButtonBox(
QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel) QtWidgets.QDialogButtonBox.StandardButton.Ok |
QtWidgets.QDialogButtonBox.StandardButton.Cancel)
grid.addWidget(buttons, 2, 0, 1, 2) grid.addWidget(buttons, 2, 0, 1, 2)
buttons.accepted.connect(self.accept) buttons.accepted.connect(self.accept)
buttons.rejected.connect(self.reject) buttons.rejected.connect(self.reject)
@ -52,7 +53,7 @@ class _OpenFileDialog(QtWidgets.QDialog):
item = QtWidgets.QListWidgetItem() item = QtWidgets.QListWidgetItem()
item.setText("..") item.setText("..")
item.setIcon(QtWidgets.QApplication.style().standardIcon( item.setIcon(QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_FileDialogToParent)) QtWidgets.QStyle.StandardPixmap.SP_FileDialogToParent))
self.file_list.addItem(item) self.file_list.addItem(item)
try: try:
@ -64,9 +65,9 @@ class _OpenFileDialog(QtWidgets.QDialog):
return return
for name in sorted(contents, key=lambda x: (x[-1] not in "\\/", x)): for name in sorted(contents, key=lambda x: (x[-1] not in "\\/", x)):
if name[-1] in "\\/": if name[-1] in "\\/":
icon = QtWidgets.QStyle.SP_DirIcon icon = QtWidgets.QStyle.StandardPixmap.SP_DirIcon
else: else:
icon = QtWidgets.QStyle.SP_FileIcon icon = QtWidgets.QStyle.StandardPixmap.SP_FileIcon
if name[-3:] != ".py": if name[-3:] != ".py":
continue continue
item = QtWidgets.QListWidgetItem() item = QtWidgets.QListWidgetItem()
@ -163,8 +164,8 @@ class ExplorerDock(QtWidgets.QDockWidget):
schedule_ctl, experiment_db_ctl, device_db_ctl): schedule_ctl, experiment_db_ctl, device_db_ctl):
QtWidgets.QDockWidget.__init__(self, "Explorer") QtWidgets.QDockWidget.__init__(self, "Explorer")
self.setObjectName("Explorer") self.setObjectName("Explorer")
self.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable | self.setFeatures(QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetMovable |
QtWidgets.QDockWidget.DockWidgetFloatable) QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetFloatable)
top_widget = LayoutWidget() top_widget = LayoutWidget()
self.setWidget(top_widget) self.setWidget(top_widget)
@ -175,7 +176,7 @@ class ExplorerDock(QtWidgets.QDockWidget):
top_widget.addWidget(QtWidgets.QLabel("Revision:"), 0, 0) top_widget.addWidget(QtWidgets.QLabel("Revision:"), 0, 0)
self.revision = QtWidgets.QLabel() self.revision = QtWidgets.QLabel()
self.revision.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse) self.revision.setTextInteractionFlags(QtCore.Qt.TextInteractionFlag.TextSelectableByMouse)
top_widget.addWidget(self.revision, 0, 1) top_widget.addWidget(self.revision, 0, 1)
self.stack = QtWidgets.QStackedWidget() self.stack = QtWidgets.QStackedWidget()
@ -187,14 +188,14 @@ class ExplorerDock(QtWidgets.QDockWidget):
self.el = QtWidgets.QTreeView() self.el = QtWidgets.QTreeView()
self.el.setHeaderHidden(True) self.el.setHeaderHidden(True)
self.el.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectItems) self.el.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectionBehavior.SelectItems)
self.el.doubleClicked.connect( self.el.doubleClicked.connect(
partial(self.expname_action, "open_experiment")) partial(self.expname_action, "open_experiment"))
self.el_buttons.addWidget(self.el, 0, 0, colspan=2) self.el_buttons.addWidget(self.el, 0, 0, colspan=2)
open = QtWidgets.QPushButton("Open") open = QtWidgets.QPushButton("Open")
open.setIcon(QtWidgets.QApplication.style().standardIcon( open.setIcon(QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_DialogOpenButton)) QtWidgets.QStyle.StandardPixmap.SP_DialogOpenButton))
open.setToolTip("Open the selected experiment (Return)") open.setToolTip("Open the selected experiment (Return)")
self.el_buttons.addWidget(open, 1, 0) self.el_buttons.addWidget(open, 1, 0)
open.clicked.connect( open.clicked.connect(
@ -202,7 +203,7 @@ class ExplorerDock(QtWidgets.QDockWidget):
submit = QtWidgets.QPushButton("Submit") submit = QtWidgets.QPushButton("Submit")
submit.setIcon(QtWidgets.QApplication.style().standardIcon( submit.setIcon(QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_DialogOkButton)) QtWidgets.QStyle.StandardPixmap.SP_DialogOkButton))
submit.setToolTip("Schedule the selected experiment (Ctrl+Return)") submit.setToolTip("Schedule the selected experiment (Ctrl+Return)")
self.el_buttons.addWidget(submit, 1, 1) self.el_buttons.addWidget(submit, 1, 1)
submit.clicked.connect( submit.clicked.connect(
@ -211,41 +212,41 @@ class ExplorerDock(QtWidgets.QDockWidget):
self.explist_model = Model(dict()) self.explist_model = Model(dict())
explist_sub.add_setmodel_callback(self.set_model) explist_sub.add_setmodel_callback(self.set_model)
self.el.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.el.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.ActionsContextMenu)
open_action = QtWidgets.QAction("Open", self.el) open_action = QtGui.QAction("Open", self.el)
open_action.triggered.connect( open_action.triggered.connect(
partial(self.expname_action, "open_experiment")) partial(self.expname_action, "open_experiment"))
open_action.setShortcut("RETURN") open_action.setShortcut("RETURN")
open_action.setShortcutContext(QtCore.Qt.WidgetShortcut) open_action.setShortcutContext(QtCore.Qt.ShortcutContext.WidgetShortcut)
self.el.addAction(open_action) self.el.addAction(open_action)
submit_action = QtWidgets.QAction("Submit", self.el) submit_action = QtGui.QAction("Submit", self.el)
submit_action.triggered.connect( submit_action.triggered.connect(
partial(self.expname_action, "submit")) partial(self.expname_action, "submit"))
submit_action.setShortcut("CTRL+RETURN") submit_action.setShortcut("CTRL+RETURN")
submit_action.setShortcutContext(QtCore.Qt.WidgetShortcut) submit_action.setShortcutContext(QtCore.Qt.ShortcutContext.WidgetShortcut)
self.el.addAction(submit_action) self.el.addAction(submit_action)
reqterm_action = QtWidgets.QAction("Request termination of instances", self.el) reqterm_action = QtGui.QAction("Request termination of instances", self.el)
reqterm_action.triggered.connect( reqterm_action.triggered.connect(
partial(self.expname_action, "request_inst_term")) partial(self.expname_action, "request_inst_term"))
reqterm_action.setShortcut("CTRL+BACKSPACE") reqterm_action.setShortcut("CTRL+BACKSPACE")
reqterm_action.setShortcutContext(QtCore.Qt.WidgetShortcut) reqterm_action.setShortcutContext(QtCore.Qt.ShortcutContext.WidgetShortcut)
self.el.addAction(reqterm_action) self.el.addAction(reqterm_action)
set_shortcut_menu = QtWidgets.QMenu() set_shortcut_menu = QtWidgets.QMenu()
for i in range(12): for i in range(12):
action = QtWidgets.QAction("F" + str(i + 1), self.el) action = QtGui.QAction("F" + str(i+1), self.el)
action.triggered.connect(partial(self.set_shortcut, i)) action.triggered.connect(partial(self.set_shortcut, i))
set_shortcut_menu.addAction(action) set_shortcut_menu.addAction(action)
set_shortcut_action = QtWidgets.QAction("Set shortcut", self.el) set_shortcut_action = QtGui.QAction("Set shortcut", self.el)
set_shortcut_action.setMenu(set_shortcut_menu) set_shortcut_action.setMenu(set_shortcut_menu)
self.el.addAction(set_shortcut_action) self.el.addAction(set_shortcut_action)
sep = QtWidgets.QAction(self.el) sep = QtGui.QAction(self.el)
sep.setSeparator(True) sep.setSeparator(True)
self.el.addAction(sep) self.el.addAction(sep)
scan_repository_action = QtWidgets.QAction("Scan repository HEAD", scan_repository_action = QtGui.QAction("Scan repository HEAD",
self.el) self.el)
def scan_repository(): def scan_repository():
@ -253,15 +254,14 @@ class ExplorerDock(QtWidgets.QDockWidget):
scan_repository_action.triggered.connect(scan_repository) scan_repository_action.triggered.connect(scan_repository)
self.el.addAction(scan_repository_action) self.el.addAction(scan_repository_action)
scan_ddb_action = QtWidgets.QAction("Scan device database", self.el) scan_ddb_action = QtGui.QAction("Scan device database", self.el)
def scan_ddb(): def scan_ddb():
asyncio.ensure_future(device_db_ctl.scan()) asyncio.ensure_future(device_db_ctl.scan())
scan_ddb_action.triggered.connect(scan_ddb) scan_ddb_action.triggered.connect(scan_ddb)
self.el.addAction(scan_ddb_action) self.el.addAction(scan_ddb_action)
self.current_directory = "" self.current_directory = ""
open_file_action = QtWidgets.QAction("Open file outside repository", open_file_action = QtGui.QAction("Open file outside repository",
self.el) self.el)
open_file_action.triggered.connect( open_file_action.triggered.connect(
lambda: _OpenFileDialog(self, self.exp_manager, lambda: _OpenFileDialog(self, self.exp_manager,

View File

@ -4,7 +4,7 @@ import textwrap
from collections import namedtuple from collections import namedtuple
from functools import partial from functools import partial
from PyQt5 import QtCore, QtWidgets from PyQt6 import QtCore, QtWidgets, QtGui
from artiq.coredevice.comm_moninj import CommMonInj, TTLOverride, TTLProbe from artiq.coredevice.comm_moninj import CommMonInj, TTLOverride, TTLProbe
from artiq.coredevice.ad9912_reg import AD9912_SER_CONF from artiq.coredevice.ad9912_reg import AD9912_SER_CONF
@ -23,7 +23,7 @@ class _CancellableLineEdit(QtWidgets.QLineEdit):
def keyPressEvent(self, event): def keyPressEvent(self, event):
key = event.key() key = event.key()
if key == QtCore.Qt.Key_Escape: if key == QtCore.Qt.Key.Key_Escape:
self.esc_cb(event) self.esc_cb(event)
QtWidgets.QLineEdit.keyPressEvent(self, event) QtWidgets.QLineEdit.keyPressEvent(self, event)
@ -31,9 +31,8 @@ class _CancellableLineEdit(QtWidgets.QLineEdit):
class _MoninjWidget(QtWidgets.QFrame): class _MoninjWidget(QtWidgets.QFrame):
def __init__(self, title): def __init__(self, title):
QtWidgets.QFrame.__init__(self) QtWidgets.QFrame.__init__(self)
self.setFrameShape(QtWidgets.QFrame.Box) self.setFrameShape(QtWidgets.QFrame.Shape.Box)
self.setFrameShape(QtWidgets.QFrame.Box) self.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
self.setFrameShadow(QtWidgets.QFrame.Raised)
self.setFixedHeight(100) self.setFixedHeight(100)
self.setFixedWidth(150) self.setFixedWidth(150)
self.grid = QtWidgets.QGridLayout() self.grid = QtWidgets.QGridLayout()
@ -43,7 +42,9 @@ class _MoninjWidget(QtWidgets.QFrame):
self.setLayout(self.grid) self.setLayout(self.grid)
title = elide(title, 20) title = elide(title, 20)
label = QtWidgets.QLabel(title) label = QtWidgets.QLabel(title)
label.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignTop) label.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
label.setSizePolicy(QtWidgets.QSizePolicy.Policy.Ignored,
QtWidgets.QSizePolicy.Policy.Preferred)
self.grid.addWidget(label, 1, 1) self.grid.addWidget(label, 1, 1)
@ -60,7 +61,7 @@ class _TTLWidget(_MoninjWidget):
self.grid.addWidget(self.stack, 2, 1) self.grid.addWidget(self.stack, 2, 1)
self.direction = QtWidgets.QLabel() self.direction = QtWidgets.QLabel()
self.direction.setAlignment(QtCore.Qt.AlignCenter) self.direction.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
self.stack.addWidget(self.direction) self.stack.addWidget(self.direction)
grid_cb = LayoutWidget() grid_cb = LayoutWidget()
@ -80,7 +81,7 @@ class _TTLWidget(_MoninjWidget):
self.stack.addWidget(grid_cb) self.stack.addWidget(grid_cb)
self.value = QtWidgets.QLabel() self.value = QtWidgets.QLabel()
self.value.setAlignment(QtCore.Qt.AlignCenter) self.value.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
self.grid.addWidget(self.value, 3, 1) self.grid.addWidget(self.value, 3, 1)
self.grid.setRowStretch(1, 1) self.grid.setRowStretch(1, 1)
@ -215,11 +216,11 @@ class _DDSWidget(_MoninjWidget):
grid_disp.layout.setVerticalSpacing(0) grid_disp.layout.setVerticalSpacing(0)
self.value_label = QtWidgets.QLabel() self.value_label = QtWidgets.QLabel()
self.value_label.setAlignment(QtCore.Qt.AlignCenter) self.value_label.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
grid_disp.addWidget(self.value_label, 0, 1, 1, 2) grid_disp.addWidget(self.value_label, 0, 1, 1, 2)
unit = QtWidgets.QLabel("MHz") unit = QtWidgets.QLabel("MHz")
unit.setAlignment(QtCore.Qt.AlignCenter) unit.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
grid_disp.addWidget(unit, 0, 3, 1, 1) grid_disp.addWidget(unit, 0, 3, 1, 1)
self.data_stack.addWidget(grid_disp) self.data_stack.addWidget(grid_disp)
@ -231,10 +232,10 @@ class _DDSWidget(_MoninjWidget):
grid_edit.layout.setVerticalSpacing(0) grid_edit.layout.setVerticalSpacing(0)
self.value_edit = _CancellableLineEdit(self) self.value_edit = _CancellableLineEdit(self)
self.value_edit.setAlignment(QtCore.Qt.AlignRight) self.value_edit.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight)
grid_edit.addWidget(self.value_edit, 0, 1, 1, 2) grid_edit.addWidget(self.value_edit, 0, 1, 1, 2)
unit = QtWidgets.QLabel("MHz") unit = QtWidgets.QLabel("MHz")
unit.setAlignment(QtCore.Qt.AlignCenter) unit.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
grid_edit.addWidget(unit, 0, 3, 1, 1) grid_edit.addWidget(unit, 0, 3, 1, 1)
self.data_stack.addWidget(grid_edit) self.data_stack.addWidget(grid_edit)
@ -799,8 +800,8 @@ class _MonInjDock(QDockWidgetCloseDetect):
def __init__(self, name, manager): def __init__(self, name, manager):
QtWidgets.QDockWidget.__init__(self, "MonInj") QtWidgets.QDockWidget.__init__(self, "MonInj")
self.setObjectName(name) self.setObjectName(name)
self.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable | self.setFeatures(QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetMovable |
QtWidgets.QDockWidget.DockWidgetFloatable) QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetFloatable)
grid = LayoutWidget() grid = LayoutWidget()
self.setWidget(grid) self.setWidget(grid)
self.manager = manager self.manager = manager

View File

@ -3,7 +3,7 @@ import time
from functools import partial from functools import partial
import logging import logging
from PyQt5 import QtCore, QtWidgets, QtGui from PyQt6 import QtCore, QtWidgets, QtGui
from artiq.gui.models import DictSyncModel from artiq.gui.models import DictSyncModel
from artiq.tools import elide from artiq.tools import elide
@ -61,31 +61,31 @@ class ScheduleDock(QtWidgets.QDockWidget):
def __init__(self, schedule_ctl, schedule_sub): def __init__(self, schedule_ctl, schedule_sub):
QtWidgets.QDockWidget.__init__(self, "Schedule") QtWidgets.QDockWidget.__init__(self, "Schedule")
self.setObjectName("Schedule") self.setObjectName("Schedule")
self.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable | self.setFeatures(QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetMovable |
QtWidgets.QDockWidget.DockWidgetFloatable) QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetFloatable)
self.schedule_ctl = schedule_ctl self.schedule_ctl = schedule_ctl
self.table = QtWidgets.QTableView() self.table = QtWidgets.QTableView()
self.table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) self.table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectionBehavior.SelectRows)
self.table.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection) self.table.setSelectionMode(QtWidgets.QAbstractItemView.SelectionMode.SingleSelection)
self.table.verticalHeader().setSectionResizeMode( self.table.verticalHeader().setSectionResizeMode(
QtWidgets.QHeaderView.ResizeToContents) QtWidgets.QHeaderView.ResizeMode.ResizeToContents)
self.table.verticalHeader().hide() self.table.verticalHeader().hide()
self.setWidget(self.table) self.setWidget(self.table)
self.table.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.table.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.ActionsContextMenu)
request_termination_action = QtWidgets.QAction("Request termination", self.table) request_termination_action = QtGui.QAction("Request termination", self.table)
request_termination_action.triggered.connect(partial(self.delete_clicked, True)) request_termination_action.triggered.connect(partial(self.delete_clicked, True))
request_termination_action.setShortcut("DELETE") request_termination_action.setShortcut("DELETE")
request_termination_action.setShortcutContext(QtCore.Qt.WidgetShortcut) request_termination_action.setShortcutContext(QtCore.Qt.ShortcutContext.WidgetShortcut)
self.table.addAction(request_termination_action) self.table.addAction(request_termination_action)
delete_action = QtWidgets.QAction("Delete", self.table) delete_action = QtGui.QAction("Delete", self.table)
delete_action.triggered.connect(partial(self.delete_clicked, False)) delete_action.triggered.connect(partial(self.delete_clicked, False))
delete_action.setShortcut("SHIFT+DELETE") delete_action.setShortcut("SHIFT+DELETE")
delete_action.setShortcutContext(QtCore.Qt.WidgetShortcut) delete_action.setShortcutContext(QtCore.Qt.ShortcutContext.WidgetShortcut)
self.table.addAction(delete_action) self.table.addAction(delete_action)
terminate_pipeline = QtWidgets.QAction( terminate_pipeline = QtGui.QAction(
"Gracefully terminate all in pipeline", self.table) "Gracefully terminate all in pipeline", self.table)
terminate_pipeline.triggered.connect(self.terminate_pipeline_clicked) terminate_pipeline.triggered.connect(self.terminate_pipeline_clicked)
self.table.addAction(terminate_pipeline) self.table.addAction(terminate_pipeline)

View File

@ -1,7 +1,7 @@
import logging import logging
from functools import partial from functools import partial
from PyQt5 import QtCore, QtWidgets from PyQt6 import QtCore, QtGui, QtWidgets
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -11,8 +11,8 @@ class ShortcutsDock(QtWidgets.QDockWidget):
def __init__(self, main_window, exp_manager): def __init__(self, main_window, exp_manager):
QtWidgets.QDockWidget.__init__(self, "Shortcuts") QtWidgets.QDockWidget.__init__(self, "Shortcuts")
self.setObjectName("Shortcuts") self.setObjectName("Shortcuts")
self.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable | self.setFeatures(QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetMovable |
QtWidgets.QDockWidget.DockWidgetFloatable) QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetFloatable)
layout = QtWidgets.QGridLayout() layout = QtWidgets.QGridLayout()
top_widget = QtWidgets.QWidget() top_widget = QtWidgets.QWidget()
@ -36,25 +36,25 @@ class ShortcutsDock(QtWidgets.QDockWidget):
layout.addWidget(QtWidgets.QLabel("F" + str(i + 1)), row, 0) layout.addWidget(QtWidgets.QLabel("F" + str(i + 1)), row, 0)
label = QtWidgets.QLabel() label = QtWidgets.QLabel()
label.setSizePolicy(QtWidgets.QSizePolicy.Ignored, label.setSizePolicy(QtWidgets.QSizePolicy.Policy.Ignored,
QtWidgets.QSizePolicy.Ignored) QtWidgets.QSizePolicy.Policy.Ignored)
layout.addWidget(label, row, 1) layout.addWidget(label, row, 1)
clear = QtWidgets.QToolButton() clear = QtWidgets.QToolButton()
clear.setIcon(QtWidgets.QApplication.style().standardIcon( clear.setIcon(QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_DialogDiscardButton)) QtWidgets.QStyle.StandardPixmap.SP_DialogDiscardButton))
layout.addWidget(clear, row, 2) layout.addWidget(clear, row, 2)
clear.clicked.connect(partial(self.set_shortcut, i, "")) clear.clicked.connect(partial(self.set_shortcut, i, ""))
open = QtWidgets.QToolButton() open = QtWidgets.QToolButton()
open.setIcon(QtWidgets.QApplication.style().standardIcon( open.setIcon(QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_DialogOpenButton)) QtWidgets.QStyle.StandardPixmap.SP_DialogOpenButton))
layout.addWidget(open, row, 3) layout.addWidget(open, row, 3)
open.clicked.connect(partial(self._open_experiment, i)) open.clicked.connect(partial(self._open_experiment, i))
submit = QtWidgets.QPushButton("Submit") submit = QtWidgets.QPushButton("Submit")
submit.setIcon(QtWidgets.QApplication.style().standardIcon( submit.setIcon(QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_DialogOkButton)) QtWidgets.QStyle.StandardPixmap.SP_DialogOkButton))
layout.addWidget(submit, row, 4) layout.addWidget(submit, row, 4)
submit.clicked.connect(partial(self._activated, i)) submit.clicked.connect(partial(self._activated, i))
@ -68,8 +68,8 @@ class ShortcutsDock(QtWidgets.QDockWidget):
"open": open, "open": open,
"submit": submit "submit": submit
} }
shortcut = QtWidgets.QShortcut("F" + str(i + 1), main_window) shortcut = QtGui.QShortcut("F" + str(i+1), main_window)
shortcut.setContext(QtCore.Qt.ApplicationShortcut) shortcut.setContext(QtCore.Qt.ShortcutContext.ApplicationShortcut)
shortcut.activated.connect(partial(self._activated, i)) shortcut.activated.connect(partial(self._activated, i))
def _activated(self, nr): def _activated(self, nr):

View File

@ -1,4 +1,4 @@
from PyQt5 import QtWidgets from PyQt6 import QtWidgets
from artiq.applets.simple import SimpleApplet from artiq.applets.simple import SimpleApplet

View File

@ -7,7 +7,7 @@ import os
import logging import logging
import sys import sys
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt6 import QtCore, QtGui, QtWidgets
from qasync import QEventLoop from qasync import QEventLoop
from sipyco.asyncio_tools import atexit_register_coroutine from sipyco.asyncio_tools import atexit_register_coroutine
@ -68,9 +68,9 @@ class Browser(QtWidgets.QMainWindow):
browse_root, dataset_sub) browse_root, dataset_sub)
smgr.register(self.experiments) smgr.register(self.experiments)
self.experiments.setHorizontalScrollBarPolicy( self.experiments.setHorizontalScrollBarPolicy(
QtCore.Qt.ScrollBarAsNeeded) QtCore.Qt.ScrollBarPolicy.ScrollBarAsNeeded)
self.experiments.setVerticalScrollBarPolicy( self.experiments.setVerticalScrollBarPolicy(
QtCore.Qt.ScrollBarAsNeeded) QtCore.Qt.ScrollBarPolicy.ScrollBarAsNeeded)
self.setCentralWidget(self.experiments) self.setCentralWidget(self.experiments)
self.files = files.FilesDock(dataset_sub, browse_root) self.files = files.FilesDock(dataset_sub, browse_root)
@ -91,29 +91,29 @@ class Browser(QtWidgets.QMainWindow):
self.log = log.LogDock(None, "log") self.log = log.LogDock(None, "log")
smgr.register(self.log) smgr.register(self.log)
self.log.setFeatures(self.log.DockWidgetMovable | self.log.setFeatures(self.log.DockWidgetFeature.DockWidgetMovable |
self.log.DockWidgetFloatable) self.log.DockWidgetFeature.DockWidgetFloatable)
self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self.files) self.addDockWidget(QtCore.Qt.DockWidgetArea.LeftDockWidgetArea, self.files)
self.addDockWidget(QtCore.Qt.BottomDockWidgetArea, self.applets) self.addDockWidget(QtCore.Qt.DockWidgetArea.BottomDockWidgetArea, self.applets)
self.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.datasets) self.addDockWidget(QtCore.Qt.DockWidgetArea.RightDockWidgetArea, self.datasets)
self.addDockWidget(QtCore.Qt.BottomDockWidgetArea, self.log) self.addDockWidget(QtCore.Qt.DockWidgetArea.BottomDockWidgetArea, self.log)
g = self.menuBar().addMenu("&Experiment") g = self.menuBar().addMenu("&Experiment")
a = QtWidgets.QAction("&Open", self) a = QtGui.QAction("&Open", self)
a.setIcon(QtWidgets.QApplication.style().standardIcon( a.setIcon(QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_DialogOpenButton)) QtWidgets.QStyle.StandardPixmap.SP_DialogOpenButton))
a.setShortcuts(QtGui.QKeySequence.Open) a.setShortcuts(QtGui.QKeySequence.StandardKey.Open)
a.setStatusTip("Open an experiment") a.setStatusTip("Open an experiment")
a.triggered.connect(self.experiments.select_experiment) a.triggered.connect(self.experiments.select_experiment)
g.addAction(a) g.addAction(a)
g = self.menuBar().addMenu("&View") g = self.menuBar().addMenu("&View")
a = QtWidgets.QAction("Cascade", self) a = QtGui.QAction("Cascade", self)
a.setStatusTip("Cascade experiment windows") a.setStatusTip("Cascade experiment windows")
a.triggered.connect(self.experiments.cascadeSubWindows) a.triggered.connect(self.experiments.cascadeSubWindows)
g.addAction(a) g.addAction(a)
a = QtWidgets.QAction("Tile", self) a = QtGui.QAction("Tile", self)
a.setStatusTip("Tile experiment windows") a.setStatusTip("Tile experiment windows")
a.triggered.connect(self.experiments.tileSubWindows) a.triggered.connect(self.experiments.tileSubWindows)
g.addAction(a) g.addAction(a)

View File

@ -7,7 +7,7 @@ import importlib
import os import os
import logging import logging
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt6 import QtCore, QtGui, QtWidgets
from qasync import QEventLoop from qasync import QEventLoop
from sipyco.pc_rpc import AsyncioClient, Client from sipyco.pc_rpc import AsyncioClient, Client
@ -186,8 +186,8 @@ def main():
main_window = MainWindow(args.server if server_name is None else server_name) main_window = MainWindow(args.server if server_name is None else server_name)
smgr.register(main_window) smgr.register(main_window)
mdi_area = MdiArea() mdi_area = MdiArea()
mdi_area.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) mdi_area.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAsNeeded)
mdi_area.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) mdi_area.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAsNeeded)
main_window.setCentralWidget(mdi_area) main_window.setCentralWidget(mdi_area)
# create UI components # create UI components
@ -257,10 +257,10 @@ def main():
d_datasets, d_applets, d_datasets, d_applets,
d_waveform, d_interactive_args d_waveform, d_interactive_args
] ]
main_window.addDockWidget(QtCore.Qt.RightDockWidgetArea, right_docks[0]) main_window.addDockWidget(QtCore.Qt.DockWidgetArea.RightDockWidgetArea, right_docks[0])
for d1, d2 in zip(right_docks, right_docks[1:]): for d1, d2 in zip(right_docks, right_docks[1:]):
main_window.tabifyDockWidget(d1, d2) main_window.tabifyDockWidget(d1, d2)
main_window.addDockWidget(QtCore.Qt.BottomDockWidgetArea, d_schedule) main_window.addDockWidget(QtCore.Qt.DockWidgetArea.BottomDockWidgetArea, d_schedule)
# load/initialize state # load/initialize state
if os.name == "nt": if os.name == "nt":

View File

@ -9,7 +9,7 @@ from functools import partial
from itertools import count from itertools import count
from types import SimpleNamespace from types import SimpleNamespace
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt6 import QtCore, QtGui, QtWidgets
from sipyco.pipe_ipc import AsyncioParentComm from sipyco.pipe_ipc import AsyncioParentComm
from sipyco.logging_tools import LogParser from sipyco.logging_tools import LogParser
@ -388,8 +388,8 @@ class _CompleterDelegate(QtWidgets.QStyledItemDelegate):
completer = QtWidgets.QCompleter() completer = QtWidgets.QCompleter()
completer.splitPath = lambda path: path.replace("/", ".").split(".") completer.splitPath = lambda path: path.replace("/", ".").split(".")
completer.setModelSorting( completer.setModelSorting(
QtWidgets.QCompleter.CaseSensitivelySortedModel) QtWidgets.QCompleter.ModelSorting.CaseSensitivelySortedModel)
completer.setCompletionRole(QtCore.Qt.DisplayRole) completer.setCompletionRole(QtCore.Qt.ItemDataRole.DisplayRole)
if hasattr(self, "model"): if hasattr(self, "model"):
# "TODO: Optimize updates in the source model" # "TODO: Optimize updates in the source model"
# - Qt (qcompleter.cpp), never ceasing to disappoint. # - Qt (qcompleter.cpp), never ceasing to disappoint.
@ -420,8 +420,8 @@ class AppletsDock(QtWidgets.QDockWidget):
""" """
QtWidgets.QDockWidget.__init__(self, "Applets") QtWidgets.QDockWidget.__init__(self, "Applets")
self.setObjectName("Applets") self.setObjectName("Applets")
self.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable | self.setFeatures(QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetMovable |
QtWidgets.QDockWidget.DockWidgetFloatable) QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetFloatable)
self.main_window = main_window self.main_window = main_window
self.dataset_sub = dataset_sub self.dataset_sub = dataset_sub
@ -435,18 +435,18 @@ class AppletsDock(QtWidgets.QDockWidget):
self.table = QtWidgets.QTreeWidget() self.table = QtWidgets.QTreeWidget()
self.table.setColumnCount(2) self.table.setColumnCount(2)
self.table.setHeaderLabels(["Name", "Command"]) self.table.setHeaderLabels(["Name", "Command"])
self.table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) self.table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectionBehavior.SelectRows)
self.table.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection) self.table.setSelectionMode(QtWidgets.QAbstractItemView.SelectionMode.SingleSelection)
self.table.header().setStretchLastSection(True) self.table.header().setStretchLastSection(True)
self.table.header().setSectionResizeMode( self.table.header().setSectionResizeMode(
QtWidgets.QHeaderView.ResizeToContents) QtWidgets.QHeaderView.ResizeMode.ResizeToContents)
self.table.setTextElideMode(QtCore.Qt.ElideNone) self.table.setTextElideMode(QtCore.Qt.TextElideMode.ElideNone)
self.table.setDragEnabled(True) self.table.setDragEnabled(True)
self.table.viewport().setAcceptDrops(True) self.table.viewport().setAcceptDrops(True)
self.table.setDropIndicatorShown(True) self.table.setDropIndicatorShown(True)
self.table.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove) self.table.setDragDropMode(QtWidgets.QAbstractItemView.DragDropMode.InternalMove)
self.setWidget(self.table) self.setWidget(self.table)
@ -454,44 +454,44 @@ class AppletsDock(QtWidgets.QDockWidget):
self.table.setItemDelegateForColumn(1, completer_delegate) self.table.setItemDelegateForColumn(1, completer_delegate)
dataset_sub.add_setmodel_callback(completer_delegate.set_model) dataset_sub.add_setmodel_callback(completer_delegate.set_model)
self.table.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.table.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.ActionsContextMenu)
new_action = QtWidgets.QAction("New applet", self.table) new_action = QtGui.QAction("New applet", self.table)
new_action.triggered.connect(partial(self.new_with_parent, self.new)) new_action.triggered.connect(partial(self.new_with_parent, self.new))
self.table.addAction(new_action) self.table.addAction(new_action)
templates_menu = QtWidgets.QMenu() templates_menu = QtWidgets.QMenu()
for name, template in _templates: for name, template in _templates:
spec = {"ty": "command", "command": template} spec = {"ty": "command", "command": template}
action = QtWidgets.QAction(name, self.table) action = QtGui.QAction(name, self.table)
action.triggered.connect(partial( action.triggered.connect(partial(
self.new_with_parent, self.new, spec=spec)) self.new_with_parent, self.new, spec=spec))
templates_menu.addAction(action) templates_menu.addAction(action)
restart_action = QtWidgets.QAction("New applet from template", self.table) restart_action = QtGui.QAction("New applet from template", self.table)
restart_action.setMenu(templates_menu) restart_action.setMenu(templates_menu)
self.table.addAction(restart_action) self.table.addAction(restart_action)
restart_action = QtWidgets.QAction("Restart selected applet or group", self.table) restart_action = QtGui.QAction("Restart selected applet or group", self.table)
restart_action.setShortcut("CTRL+R") restart_action.setShortcut("CTRL+R")
restart_action.setShortcutContext(QtCore.Qt.WidgetShortcut) restart_action.setShortcutContext(QtCore.Qt.ShortcutContext.WidgetShortcut)
restart_action.triggered.connect(self.restart) restart_action.triggered.connect(self.restart)
self.table.addAction(restart_action) self.table.addAction(restart_action)
delete_action = QtWidgets.QAction("Delete selected applet or group", self.table) delete_action = QtGui.QAction("Delete selected applet or group", self.table)
delete_action.setShortcut("DELETE") delete_action.setShortcut("DELETE")
delete_action.setShortcutContext(QtCore.Qt.WidgetShortcut) delete_action.setShortcutContext(QtCore.Qt.ShortcutContext.WidgetShortcut)
delete_action.triggered.connect(self.delete) delete_action.triggered.connect(self.delete)
self.table.addAction(delete_action) self.table.addAction(delete_action)
close_nondocked_action = QtWidgets.QAction("Close non-docked applets", self.table) close_nondocked_action = QtGui.QAction("Close non-docked applets", self.table)
close_nondocked_action.setShortcut("CTRL+ALT+W") close_nondocked_action.setShortcut("CTRL+ALT+W")
close_nondocked_action.setShortcutContext(QtCore.Qt.ApplicationShortcut) close_nondocked_action.setShortcutContext(QtCore.Qt.ShortcutContext.ApplicationShortcut)
close_nondocked_action.triggered.connect(self.close_nondocked) close_nondocked_action.triggered.connect(self.close_nondocked)
self.table.addAction(close_nondocked_action) self.table.addAction(close_nondocked_action)
new_group_action = QtWidgets.QAction("New group", self.table) new_group_action = QtGui.QAction("New group", self.table)
new_group_action.triggered.connect(partial(self.new_with_parent, self.new_group)) new_group_action.triggered.connect(partial(self.new_with_parent, self.new_group))
self.table.addAction(new_group_action) self.table.addAction(new_group_action)
self.table.itemChanged.connect(self.item_changed) self.table.itemChanged.connect(self.item_changed)
# HACK # HACK
self.table.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) self.table.setEditTriggers(QtWidgets.QAbstractItemView.EditTrigger.NoEditTriggers)
self.table.itemDoubleClicked.connect(self.open_editor) self.table.itemDoubleClicked.connect(self.open_editor)
def open_editor(self, item, column): def open_editor(self, item, column):
@ -518,7 +518,7 @@ class AppletsDock(QtWidgets.QDockWidget):
del item.applet_code del item.applet_code
elif spec["ty"] == "code": elif spec["ty"] == "code":
item.setIcon(1, QtWidgets.QApplication.style().standardIcon( item.setIcon(1, QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_FileIcon)) QtWidgets.QStyle.StandardPixmap.SP_FileIcon))
item.applet_code = spec["code"] item.applet_code = spec["code"]
else: else:
raise ValueError raise ValueError
@ -530,7 +530,7 @@ class AppletsDock(QtWidgets.QDockWidget):
def create(self, item, name, spec): def create(self, item, name, spec):
dock = _AppletDock(self.dataset_sub, self.dataset_ctl, self.expmgr, item.applet_uid, name, spec, self.extra_substitutes) dock = _AppletDock(self.dataset_sub, self.dataset_ctl, self.expmgr, item.applet_uid, name, spec, self.extra_substitutes)
self.main_window.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock) self.main_window.addDockWidget(QtCore.Qt.DockWidgetArea.RightDockWidgetArea, dock)
dock.setFloating(True) dock.setFloating(True)
asyncio.ensure_future(dock.start(), loop=self._loop) asyncio.ensure_future(dock.start(), loop=self._loop)
dock.sigClosed.connect(partial(self.on_dock_closed, item, dock)) dock.sigClosed.connect(partial(self.on_dock_closed, item, dock))
@ -547,7 +547,7 @@ class AppletsDock(QtWidgets.QDockWidget):
dock.spec = self.get_spec(item) dock.spec = self.get_spec(item)
if column == 0: if column == 0:
if item.checkState(0) == QtCore.Qt.Checked: if item.checkState(0) == QtCore.Qt.CheckState.Checked:
if item.applet_dock is None: if item.applet_dock is None:
name = item.text(0) name = item.text(0)
spec = self.get_spec(item) spec = self.get_spec(item)
@ -572,7 +572,7 @@ class AppletsDock(QtWidgets.QDockWidget):
def on_dock_closed(self, item, dock): def on_dock_closed(self, item, dock):
item.applet_geometry = dock.saveGeometry() item.applet_geometry = dock.saveGeometry()
asyncio.ensure_future(dock.terminate(), loop=self._loop) asyncio.ensure_future(dock.terminate(), loop=self._loop)
item.setCheckState(0, QtCore.Qt.Unchecked) item.setCheckState(0, QtCore.Qt.CheckState.Unchecked)
def get_untitled(self): def get_untitled(self):
existing_names = set() existing_names = set()
@ -602,18 +602,18 @@ class AppletsDock(QtWidgets.QDockWidget):
name = self.get_untitled() name = self.get_untitled()
item = QtWidgets.QTreeWidgetItem([name, ""]) item = QtWidgets.QTreeWidgetItem([name, ""])
item.ty = "applet" item.ty = "applet"
item.setFlags(QtCore.Qt.ItemIsSelectable | item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable |
QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemFlag.ItemIsUserCheckable |
QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemFlag.ItemIsEditable |
QtCore.Qt.ItemIsDragEnabled | QtCore.Qt.ItemFlag.ItemIsDragEnabled |
QtCore.Qt.ItemNeverHasChildren | QtCore.Qt.ItemFlag.ItemNeverHasChildren |
QtCore.Qt.ItemIsEnabled) QtCore.Qt.ItemFlag.ItemIsEnabled)
item.setCheckState(0, QtCore.Qt.Unchecked) item.setCheckState(0, QtCore.Qt.CheckState.Unchecked)
item.applet_uid = uid item.applet_uid = uid
item.applet_dock = None item.applet_dock = None
item.applet_geometry = None item.applet_geometry = None
item.setIcon(0, QtWidgets.QApplication.style().standardIcon( item.setIcon(0, QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_ComputerIcon)) QtWidgets.QStyle.StandardPixmap.SP_ComputerIcon))
self.set_spec(item, spec) self.set_spec(item, spec)
if parent is None: if parent is None:
self.table.addTopLevelItem(item) self.table.addTopLevelItem(item)
@ -626,15 +626,15 @@ class AppletsDock(QtWidgets.QDockWidget):
name = self.get_untitled() name = self.get_untitled()
item = QtWidgets.QTreeWidgetItem([name, attr]) item = QtWidgets.QTreeWidgetItem([name, attr])
item.ty = "group" item.ty = "group"
item.setFlags(QtCore.Qt.ItemIsSelectable | item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable |
QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemFlag.ItemIsEditable |
QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemFlag.ItemIsUserCheckable |
QtCore.Qt.ItemIsTristate | QtCore.Qt.ItemFlag.ItemIsAutoTristate |
QtCore.Qt.ItemIsDragEnabled | QtCore.Qt.ItemFlag.ItemIsDragEnabled |
QtCore.Qt.ItemIsDropEnabled | QtCore.Qt.ItemFlag.ItemIsDropEnabled |
QtCore.Qt.ItemIsEnabled) QtCore.Qt.ItemFlag.ItemIsEnabled)
item.setIcon(0, QtWidgets.QApplication.style().standardIcon( item.setIcon(0, QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_DirIcon)) QtWidgets.QStyle.StandardPixmap.SP_DirIcon))
if parent is None: if parent is None:
self.table.addTopLevelItem(item) self.table.addTopLevelItem(item)
else: else:
@ -712,7 +712,7 @@ class AppletsDock(QtWidgets.QDockWidget):
cwi = wi.child(row) cwi = wi.child(row)
if cwi.ty == "applet": if cwi.ty == "applet":
uid = cwi.applet_uid uid = cwi.applet_uid
enabled = cwi.checkState(0) == QtCore.Qt.Checked enabled = cwi.checkState(0) == QtCore.Qt.CheckState.Checked
name = cwi.text(0) name = cwi.text(0)
spec = self.get_spec(cwi) spec = self.get_spec(cwi)
geometry = cwi.applet_geometry geometry = cwi.applet_geometry
@ -744,7 +744,7 @@ class AppletsDock(QtWidgets.QDockWidget):
geometry = QtCore.QByteArray(geometry) geometry = QtCore.QByteArray(geometry)
item.applet_geometry = geometry item.applet_geometry = geometry
if enabled: if enabled:
item.setCheckState(0, QtCore.Qt.Checked) item.setCheckState(0, QtCore.Qt.CheckState.Checked)
elif wis[0] == "group": elif wis[0] == "group":
_, name, attr, expanded, state_child = wis _, name, attr, expanded, state_child = wis
item = self.new_group(name, attr, parent=parent) item = self.new_group(name, attr, parent=parent)
@ -761,11 +761,11 @@ class AppletsDock(QtWidgets.QDockWidget):
for i in range(wi.childCount()): for i in range(wi.childCount()):
cwi = wi.child(i) cwi = wi.child(i)
if cwi.ty == "applet": if cwi.ty == "applet":
if cwi.checkState(0) == QtCore.Qt.Checked: if cwi.checkState(0) == QtCore.Qt.CheckState.Checked:
if cwi.applet_dock is not None: if cwi.applet_dock is not None:
if not cwi.applet_dock.isFloating(): if not cwi.applet_dock.isFloating():
continue continue
cwi.setCheckState(0, QtCore.Qt.Unchecked) cwi.setCheckState(0, QtCore.Qt.CheckState.Unchecked)
elif cwi.ty == "group": elif cwi.ty == "group":
walk(cwi) walk(cwi)
walk(self.table.invisibleRootItem()) walk(self.table.invisibleRootItem())

View File

@ -2,7 +2,7 @@ import logging
from collections import OrderedDict from collections import OrderedDict
from functools import partial from functools import partial
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt6 import QtCore, QtGui, QtWidgets
from artiq.gui.tools import LayoutWidget, disable_scroll_wheel, WheelFilter from artiq.gui.tools import LayoutWidget, disable_scroll_wheel, WheelFilter
from artiq.gui.scanwidget import ScanWidget from artiq.gui.scanwidget import ScanWidget
@ -540,7 +540,8 @@ class _ExplicitScan(LayoutWidget):
float_regexp = r"(([+-]?\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?)" float_regexp = r"(([+-]?\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?)"
regexp = "(float)?( +float)* *".replace("float", float_regexp) regexp = "(float)?( +float)* *".replace("float", float_regexp)
self.value.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp(regexp))) self.value.setValidator(QtGui.QRegularExpressionValidator(
QtCore.QRegularExpression(regexp)))
self.value.setText(" ".join([str(x) for x in state["sequence"]])) self.value.setText(" ".join([str(x) for x in state["sequence"]]))
def update(text): def update(text):

View File

@ -39,8 +39,8 @@
############################################################################# #############################################################################
from PyQt5.QtCore import QPoint, QRect, QSize, Qt from PyQt6.QtCore import QPoint, QRect, QSize, Qt
from PyQt5.QtWidgets import (QApplication, QLayout, QPushButton, QSizePolicy, from PyQt6.QtWidgets import (QApplication, QLayout, QPushButton, QSizePolicy,
QWidget) QWidget)
@ -113,8 +113,8 @@ class FlowLayout(QLayout):
for item in self.itemList: for item in self.itemList:
wid = item.widget() wid = item.widget()
spaceX = self.spacing() + wid.style().layoutSpacing(QSizePolicy.PushButton, QSizePolicy.PushButton, Qt.Horizontal) spaceX = self.spacing() + wid.style().layoutSpacing(QSizePolicy.ControlType.PushButton, QSizePolicy.ControlType.PushButton, Qt.Orientation.Horizontal)
spaceY = self.spacing() + wid.style().layoutSpacing(QSizePolicy.PushButton, QSizePolicy.PushButton, Qt.Vertical) spaceY = self.spacing() + wid.style().layoutSpacing(QSizePolicy.ControlType.PushButton, QSizePolicy.ControlType.PushButton, Qt.Orientation.Vertical)
nextX = x + item.sizeHint().width() + spaceX nextX = x + item.sizeHint().width() + spaceX
if nextX - spaceX > rect.right() and lineHeight > 0: if nextX - spaceX > rect.right() and lineHeight > 0:
x = rect.x() x = rect.x()

View File

@ -2,7 +2,7 @@ import re
from functools import partial from functools import partial
from typing import List, Tuple from typing import List, Tuple
from PyQt5 import QtCore, QtWidgets from PyQt6 import QtCore, QtGui, QtWidgets
from artiq.gui.tools import LayoutWidget from artiq.gui.tools import LayoutWidget
@ -19,7 +19,7 @@ class FuzzySelectWidget(LayoutWidget):
#: Raised when an entry has been selected, giving the label of the user #: Raised when an entry has been selected, giving the label of the user
#: choice and any additional QEvent.modifiers() (e.g. Ctrl key pressed). #: choice and any additional QEvent.modifiers() (e.g. Ctrl key pressed).
finished = QtCore.pyqtSignal(str, int) finished = QtCore.pyqtSignal(str, QtCore.Qt.KeyboardModifier)
def __init__(self, def __init__(self,
choices: List[Tuple[str, int]] = [], choices: List[Tuple[str, int]] = [],
@ -138,16 +138,16 @@ class FuzzySelectWidget(LayoutWidget):
first_action = None first_action = None
last_action = None last_action = None
for choice in filtered_choices: for choice in filtered_choices:
action = QtWidgets.QAction(choice, self.menu) action = QtGui.QAction(choice, self.menu)
action.triggered.connect(partial(self._finish, action, choice)) action.triggered.connect(partial(self._finish, action, choice))
action.modifiers = 0 action.modifiers = QtCore.Qt.KeyboardModifier.NoModifier
self.menu.addAction(action) self.menu.addAction(action)
if not first_action: if not first_action:
first_action = action first_action = action
last_action = action last_action = action
if num_omitted > 0: if num_omitted > 0:
action = QtWidgets.QAction("<{} not shown>".format(num_omitted), action = QtGui.QAction("<{} not shown>".format(num_omitted),
self.menu) self.menu)
action.setEnabled(False) action.setEnabled(False)
self.menu.addAction(action) self.menu.addAction(action)
@ -239,9 +239,9 @@ class _FocusEventFilter(QtCore.QObject):
focus_lost = QtCore.pyqtSignal() focus_lost = QtCore.pyqtSignal()
def eventFilter(self, obj, event): def eventFilter(self, obj, event):
if event.type() == QtCore.QEvent.FocusIn: if event.type() == QtCore.QEvent.Type.FocusIn:
self.focus_gained.emit() self.focus_gained.emit()
elif event.type() == QtCore.QEvent.FocusOut: elif event.type() == QtCore.QEvent.Type.FocusOut:
self.focus_lost.emit() self.focus_lost.emit()
return False return False
@ -251,8 +251,8 @@ class _EscapeKeyFilter(QtCore.QObject):
escape_pressed = QtCore.pyqtSignal() escape_pressed = QtCore.pyqtSignal()
def eventFilter(self, obj, event): def eventFilter(self, obj, event):
if event.type() == QtCore.QEvent.KeyPress: if event.type() == QtCore.QEvent.Type.KeyPress:
if event.key() == QtCore.Qt.Key_Escape: if event.key() == QtCore.Qt.Key.Key_Escape:
self.escape_pressed.emit() self.escape_pressed.emit()
return False return False
@ -266,13 +266,13 @@ class _UpDownKeyFilter(QtCore.QObject):
self.last_item = last_item self.last_item = last_item
def eventFilter(self, obj, event): def eventFilter(self, obj, event):
if event.type() == QtCore.QEvent.KeyPress: if event.type() == QtCore.QEvent.Type.KeyPress:
if event.key() == QtCore.Qt.Key_Down: if event.key() == QtCore.Qt.Key.Key_Down:
self.menu.setActiveAction(self.first_item) self.menu.setActiveAction(self.first_item)
self.menu.setFocus() self.menu.setFocus()
return True return True
if event.key() == QtCore.Qt.Key_Up: if event.key() == QtCore.Qt.Key.Key_Up:
self.menu.setActiveAction(self.last_item) self.menu.setActiveAction(self.last_item)
self.menu.setFocus() self.menu.setFocus()
return True return True
@ -286,16 +286,16 @@ class _NonUpDownKeyFilter(QtCore.QObject):
self.target = target self.target = target
def eventFilter(self, obj, event): def eventFilter(self, obj, event):
if event.type() == QtCore.QEvent.KeyPress: if event.type() == QtCore.QEvent.Type.KeyPress:
k = event.key() k = event.key()
if k in (QtCore.Qt.Key_Return, QtCore.Qt.Key_Enter): if k in (QtCore.Qt.Key.Key_Return, QtCore.Qt.Key.Key_Enter):
action = obj.activeAction() action = obj.activeAction()
if action is not None: if action is not None:
action.modifiers = event.modifiers() action.modifiers = event.modifiers()
return False return False
if (k != QtCore.Qt.Key_Down and k != QtCore.Qt.Key_Up if (k != QtCore.Qt.Key.Key_Down and k != QtCore.Qt.Key.Key_Up
and k != QtCore.Qt.Key_Enter and k != QtCore.Qt.Key.Key_Enter
and k != QtCore.Qt.Key_Return): and k != QtCore.Qt.Key.Key_Return):
QtWidgets.QApplication.sendEvent(self.target, event) QtWidgets.QApplication.sendEvent(self.target, event)
return True return True
return False return False

View File

@ -3,7 +3,7 @@ import time
import re import re
from functools import partial from functools import partial
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt6 import QtCore, QtGui, QtWidgets
from sipyco.logging_tools import SourceFilter from sipyco.logging_tools import SourceFilter
from artiq.gui.tools import (LayoutWidget, log_level_to_name, from artiq.gui.tools import (LayoutWidget, log_level_to_name,
@ -20,7 +20,7 @@ class _ModelItem:
class _LogFilterProxyModel(QtCore.QSortFilterProxyModel): class _LogFilterProxyModel(QtCore.QSortFilterProxyModel):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.setFilterCaseSensitivity(QtCore.Qt.CaseInsensitive) self.setFilterCaseSensitivity(QtCore.Qt.CaseSensitivity.CaseInsensitive)
self.setRecursiveFilteringEnabled(True) self.setRecursiveFilteringEnabled(True)
self.filter_level = 0 self.filter_level = 0
@ -28,13 +28,13 @@ class _LogFilterProxyModel(QtCore.QSortFilterProxyModel):
source = self.sourceModel() source = self.sourceModel()
index0 = source.index(source_row, 0, source_parent) index0 = source.index(source_row, 0, source_parent)
index1 = source.index(source_row, 1, source_parent) index1 = source.index(source_row, 1, source_parent)
level = source.data(index0, QtCore.Qt.UserRole) level = source.data(index0, QtCore.Qt.ItemDataRole.UserRole)
if level >= self.filter_level: if level >= self.filter_level:
regex = self.filterRegExp() regex = self.filterRegularExpression()
index0_text = source.data(index0, QtCore.Qt.DisplayRole) index0_text = source.data(index0, QtCore.Qt.ItemDataRole.DisplayRole)
msg_text = source.data(index1, QtCore.Qt.DisplayRole) msg_text = source.data(index1, QtCore.Qt.ItemDataRole.DisplayRole)
return (regex.indexIn(index0_text) != -1 or regex.indexIn(msg_text) != -1) return (regex.match(index0_text).hasMatch() or regex.match(msg_text).hasMatch())
else: else:
return False return False
@ -57,7 +57,7 @@ class _Model(QtCore.QAbstractItemModel):
timer.timeout.connect(self.timer_tick) timer.timeout.connect(self.timer_tick)
timer.start(100) timer.start(100)
self.fixed_font = QtGui.QFontDatabase.systemFont(QtGui.QFontDatabase.FixedFont) self.fixed_font = QtGui.QFontDatabase.systemFont(QtGui.QFontDatabase.SystemFont.FixedFont)
self.white = QtGui.QBrush(QtGui.QColor(255, 255, 255)) self.white = QtGui.QBrush(QtGui.QColor(255, 255, 255))
self.black = QtGui.QBrush(QtGui.QColor(0, 0, 0)) self.black = QtGui.QBrush(QtGui.QColor(0, 0, 0))
@ -66,8 +66,8 @@ class _Model(QtCore.QAbstractItemModel):
self.error_bg = QtGui.QBrush(QtGui.QColor(255, 150, 150)) self.error_bg = QtGui.QBrush(QtGui.QColor(255, 150, 150))
def headerData(self, col, orientation, role): def headerData(self, col, orientation, role):
if (orientation == QtCore.Qt.Horizontal if (orientation == QtCore.Qt.Orientation.Horizontal
and role == QtCore.Qt.DisplayRole): and role == QtCore.Qt.ItemDataRole.DisplayRole):
return self.headers[col] return self.headers[col]
return None return None
@ -155,9 +155,9 @@ class _Model(QtCore.QAbstractItemModel):
else: else:
msgnum = item.parent.row msgnum = item.parent.row
if role == QtCore.Qt.FontRole and index.column() == 1: if role == QtCore.Qt.ItemDataRole.FontRole and index.column() == 1:
return self.fixed_font return self.fixed_font
elif role == QtCore.Qt.BackgroundRole: elif role == QtCore.Qt.ItemDataRole.BackgroundRole:
level = self.entries[msgnum][0] level = self.entries[msgnum][0]
if level >= logging.ERROR: if level >= logging.ERROR:
return self.error_bg return self.error_bg
@ -165,13 +165,13 @@ class _Model(QtCore.QAbstractItemModel):
return self.warning_bg return self.warning_bg
else: else:
return self.white return self.white
elif role == QtCore.Qt.ForegroundRole: elif role == QtCore.Qt.ItemDataRole.ForegroundRole:
level = self.entries[msgnum][0] level = self.entries[msgnum][0]
if level <= logging.DEBUG: if level <= logging.DEBUG:
return self.debug_fg return self.debug_fg
else: else:
return self.black return self.black
elif role == QtCore.Qt.DisplayRole: elif role == QtCore.Qt.ItemDataRole.DisplayRole:
v = self.entries[msgnum] v = self.entries[msgnum]
column = index.column() column = index.column()
if item.parent is self: if item.parent is self:
@ -184,7 +184,7 @@ class _Model(QtCore.QAbstractItemModel):
return "" return ""
else: else:
return v[3][item.row+1] return v[3][item.row+1]
elif role == QtCore.Qt.ToolTipRole: elif role == QtCore.Qt.ItemDataRole.ToolTipRole:
v = self.entries[msgnum] v = self.entries[msgnum]
if item.parent is self: if item.parent is self:
lineno = 0 lineno = 0
@ -193,7 +193,7 @@ class _Model(QtCore.QAbstractItemModel):
return (log_level_to_name(v[0]) + ", " + return (log_level_to_name(v[0]) + ", " +
time.strftime("%m/%d %H:%M:%S", time.localtime(v[2])) + time.strftime("%m/%d %H:%M:%S", time.localtime(v[2])) +
"\n" + v[3][lineno]) "\n" + v[3][lineno])
elif role == QtCore.Qt.UserRole: elif role == QtCore.Qt.ItemDataRole.UserRole:
return self.entries[msgnum][0] return self.entries[msgnum][0]
@ -218,13 +218,13 @@ class LogDock(QDockWidgetCloseDetect):
scrollbottom = QtWidgets.QToolButton() scrollbottom = QtWidgets.QToolButton()
scrollbottom.setToolTip("Scroll to bottom") scrollbottom.setToolTip("Scroll to bottom")
scrollbottom.setIcon(QtWidgets.QApplication.style().standardIcon( scrollbottom.setIcon(QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_ArrowDown)) QtWidgets.QStyle.StandardPixmap.SP_ArrowDown))
grid.addWidget(scrollbottom, 0, 3) grid.addWidget(scrollbottom, 0, 3)
scrollbottom.clicked.connect(self.scroll_to_bottom) scrollbottom.clicked.connect(self.scroll_to_bottom)
clear = QtWidgets.QToolButton() clear = QtWidgets.QToolButton()
clear.setIcon(QtWidgets.QApplication.style().standardIcon( clear.setIcon(QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_DialogResetButton)) QtWidgets.QStyle.StandardPixmap.SP_DialogResetButton))
grid.addWidget(clear, 0, 4) grid.addWidget(clear, 0, 4)
clear.clicked.connect(lambda: self.model.clear()) clear.clicked.connect(lambda: self.model.clear())
@ -232,7 +232,7 @@ class LogDock(QDockWidgetCloseDetect):
newdock = QtWidgets.QToolButton() newdock = QtWidgets.QToolButton()
newdock.setToolTip("Create new log dock") newdock.setToolTip("Create new log dock")
newdock.setIcon(QtWidgets.QApplication.style().standardIcon( newdock.setIcon(QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_FileDialogNewFolder)) QtWidgets.QStyle.StandardPixmap.SP_FileDialogNewFolder))
# note the lambda, the default parameter is overriden otherwise # note the lambda, the default parameter is overriden otherwise
newdock.clicked.connect(lambda: manager.create_new_dock()) newdock.clicked.connect(lambda: manager.create_new_dock())
grid.addWidget(newdock, 0, 5) grid.addWidget(newdock, 0, 5)
@ -240,27 +240,27 @@ class LogDock(QDockWidgetCloseDetect):
self.log = QtWidgets.QTreeView() self.log = QtWidgets.QTreeView()
self.log.setHorizontalScrollMode( self.log.setHorizontalScrollMode(
QtWidgets.QAbstractItemView.ScrollPerPixel) QtWidgets.QAbstractItemView.ScrollMode.ScrollPerPixel)
self.log.setVerticalScrollMode( self.log.setVerticalScrollMode(
QtWidgets.QAbstractItemView.ScrollPerPixel) QtWidgets.QAbstractItemView.ScrollMode.ScrollPerPixel)
self.log.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) self.log.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAsNeeded)
grid.addWidget(self.log, 1, 0, colspan=6 if manager else 5) grid.addWidget(self.log, 1, 0, colspan=6 if manager else 5)
self.scroll_at_bottom = False self.scroll_at_bottom = False
self.scroll_value = 0 self.scroll_value = 0
self.log.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.log.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.ActionsContextMenu)
copy_action = QtWidgets.QAction("Copy entry to clipboard", self.log) copy_action = QtGui.QAction("Copy entry to clipboard", self.log)
copy_action.triggered.connect(self.copy_to_clipboard) copy_action.triggered.connect(self.copy_to_clipboard)
self.log.addAction(copy_action) self.log.addAction(copy_action)
clear_action = QtWidgets.QAction("Clear", self.log) clear_action = QtGui.QAction("Clear", self.log)
clear_action.triggered.connect(lambda: self.model.clear()) clear_action.triggered.connect(lambda: self.model.clear())
self.log.addAction(clear_action) self.log.addAction(clear_action)
# If Qt worked correctly, this would be nice to have. Alas, resizeSections # If Qt worked correctly, this would be nice to have. Alas, resizeSections
# is broken when the horizontal scrollbar is enabled. # is broken when the horizontal scrollbar is enabled.
# sizeheader_action = QtWidgets.QAction("Resize header", self.log) # sizeheader_action = QtGui.QAction("Resize header", self.log)
# sizeheader_action.triggered.connect( # sizeheader_action.triggered.connect(
# lambda: self.log.header().resizeSections(QtWidgets.QHeaderView.ResizeToContents)) # lambda: self.log.header().resizeSections(QtWidgets.QHeaderView.ResizeMode.ResizeToContents))
# self.log.addAction(sizeheader_action) # self.log.addAction(sizeheader_action)
cw = QtGui.QFontMetrics(self.font()).averageCharWidth() cw = QtGui.QFontMetrics(self.font()).averageCharWidth()
@ -279,7 +279,7 @@ class LogDock(QDockWidgetCloseDetect):
self.filter_level.currentIndexChanged.connect(self.apply_level_filter) self.filter_level.currentIndexChanged.connect(self.apply_level_filter)
def apply_text_filter(self): def apply_text_filter(self):
self.proxy_model.setFilterRegExp(self.filter_freetext.text()) self.proxy_model.setFilterRegularExpression(self.filter_freetext.text())
def apply_level_filter(self): def apply_level_filter(self):
self.proxy_model.apply_filter_level(self.filter_level.currentText()) self.proxy_model.apply_filter_level(self.filter_level.currentText())
@ -366,7 +366,7 @@ class LogDockManager:
dock = LogDock(self, name) dock = LogDock(self, name)
self.docks[name] = dock self.docks[name] = dock
if add_to_area: if add_to_area:
self.main_window.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock) self.main_window.addDockWidget(QtCore.Qt.DockWidgetArea.RightDockWidgetArea, dock)
dock.setFloating(True) dock.setFloating(True)
dock.sigClosed.connect(partial(self.on_dock_closed, name)) dock.sigClosed.connect(partial(self.on_dock_closed, name))
self.update_closable() self.update_closable()
@ -379,8 +379,8 @@ class LogDockManager:
self.update_closable() self.update_closable()
def update_closable(self): def update_closable(self):
flags = (QtWidgets.QDockWidget.DockWidgetMovable | flags = (QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetMovable |
QtWidgets.QDockWidget.DockWidgetFloatable) QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetFloatable)
if len(self.docks) > 1: if len(self.docks) > 1:
flags |= QtWidgets.QDockWidget.DockWidgetClosable flags |= QtWidgets.QDockWidget.DockWidgetClosable
for dock in self.docks.values(): for dock in self.docks.values():
@ -396,7 +396,7 @@ class LogDockManager:
dock = LogDock(self, name) dock = LogDock(self, name)
self.docks[name] = dock self.docks[name] = dock
dock.restore_state(dock_state) dock.restore_state(dock_state)
self.main_window.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock) self.main_window.addDockWidget(QtCore.Qt.DockWidgetArea.RightDockWidgetArea, dock)
dock.sigClosed.connect(partial(self.on_dock_closed, name)) dock.sigClosed.connect(partial(self.on_dock_closed, name))
self.update_closable() self.update_closable()

View File

@ -1,4 +1,4 @@
from PyQt5 import QtCore from PyQt6 import QtCore
from sipyco.sync_struct import Subscriber, process_mod from sipyco.sync_struct import Subscriber, process_mod
@ -91,15 +91,15 @@ class DictSyncModel(QtCore.QAbstractTableModel):
return len(self.headers) return len(self.headers)
def data(self, index, role): def data(self, index, role):
if not index.isValid() or role != QtCore.Qt.DisplayRole: if not index.isValid() or role != QtCore.Qt.ItemDataRole.DisplayRole:
return None return None
else: else:
k = self.row_to_key[index.row()] k = self.row_to_key[index.row()]
return self.convert(k, self.backing_store[k], index.column()) return self.convert(k, self.backing_store[k], index.column())
def headerData(self, col, orientation, role): def headerData(self, col, orientation, role):
if (orientation == QtCore.Qt.Horizontal and if (orientation == QtCore.Qt.Orientation.Horizontal and
role == QtCore.Qt.DisplayRole): role == QtCore.Qt.ItemDataRole.DisplayRole):
return self.headers[col] return self.headers[col]
return None return None
@ -170,15 +170,15 @@ class ListSyncModel(QtCore.QAbstractTableModel):
return len(self.headers) return len(self.headers)
def data(self, index, role): def data(self, index, role):
if not index.isValid() or role != QtCore.Qt.DisplayRole: if not index.isValid() or role != QtCore.Qt.ItemDataRole.DisplayRole:
return None return None
else: else:
return self.convert(self.backing_store[index.row()], return self.convert(self.backing_store[index.row()],
index.column()) index.column())
def headerData(self, col, orientation, role): def headerData(self, col, orientation, role):
if (orientation == QtCore.Qt.Horizontal and if (orientation == QtCore.Qt.Orientation.Horizontal and
role == QtCore.Qt.DisplayRole): role == QtCore.Qt.ItemDataRole.DisplayRole):
return self.headers[col] return self.headers[col]
return None return None
@ -271,8 +271,8 @@ class DictSyncTreeSepModel(QtCore.QAbstractItemModel):
return len(self.headers) return len(self.headers)
def headerData(self, col, orientation, role): def headerData(self, col, orientation, role):
if (orientation == QtCore.Qt.Horizontal and if (orientation == QtCore.Qt.Orientation.Horizontal and
role == QtCore.Qt.DisplayRole): role == QtCore.Qt.ItemDataRole.DisplayRole):
return self.headers[col] return self.headers[col]
return None return None
@ -394,19 +394,19 @@ class DictSyncTreeSepModel(QtCore.QAbstractItemModel):
return key return key
def data(self, index, role): def data(self, index, role):
if not index.isValid() or (role != QtCore.Qt.DisplayRole if not index.isValid() or (role != QtCore.Qt.ItemDataRole.DisplayRole
and role != QtCore.Qt.ToolTipRole): and role != QtCore.Qt.ItemDataRole.ToolTipRole):
return None return None
else: else:
column = index.column() column = index.column()
if column == 0 and role == QtCore.Qt.DisplayRole: if column == 0 and role == QtCore.Qt.ItemDataRole.DisplayRole:
return index.internalPointer().name return index.internalPointer().name
else: else:
key = self.index_to_key(index) key = self.index_to_key(index)
if key is None: if key is None:
return None return None
else: else:
if role == QtCore.Qt.DisplayRole: if role == QtCore.Qt.ItemDataRole.DisplayRole:
convert = self.convert convert = self.convert
else: else:
convert = self.convert_tooltip convert = self.convert_tooltip

View File

@ -1,6 +1,6 @@
import logging import logging
from PyQt5 import QtGui, QtCore, QtWidgets from PyQt6 import QtGui, QtCore, QtWidgets
import numpy as np import numpy as np
from .ticker import Ticker from .ticker import Ticker
@ -23,15 +23,15 @@ class ScanWidget(QtWidgets.QWidget):
self.ticker = Ticker() self.ticker = Ticker()
self.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.ActionsContextMenu)
action = QtWidgets.QAction("V&iew range", self) action = QtGui.QAction("V&iew range", self)
action.setShortcut(QtGui.QKeySequence("CTRL+i")) action.setShortcut(QtGui.QKeySequence("CTRL+i"))
action.setShortcutContext(QtCore.Qt.WidgetShortcut) action.setShortcutContext(QtCore.Qt.ShortcutContext.WidgetShortcut)
action.triggered.connect(self.viewRange) action.triggered.connect(self.viewRange)
self.addAction(action) self.addAction(action)
action = QtWidgets.QAction("Sna&p range", self) action = QtGui.QAction("Sna&p range", self)
action.setShortcut(QtGui.QKeySequence("CTRL+p")) action.setShortcut(QtGui.QKeySequence("CTRL+p"))
action.setShortcutContext(QtCore.Qt.WidgetShortcut) action.setShortcutContext(QtCore.Qt.ShortcutContext.WidgetShortcut)
action.triggered.connect(self.snapRange) action.triggered.connect(self.snapRange)
self.addAction(action) self.addAction(action)
@ -143,56 +143,56 @@ class ScanWidget(QtWidgets.QWidget):
if ev.buttons() ^ ev.button(): # buttons changed if ev.buttons() ^ ev.button(): # buttons changed
ev.ignore() ev.ignore()
return return
if ev.modifiers() & QtCore.Qt.ShiftModifier: if ev.modifiers() & QtCore.Qt.KeyboardModifier.ShiftModifier:
self._drag = "select" self._drag = "select"
self.setStart(self._pixelToAxis(ev.x())) self.setStart(self._pixelToAxis(ev.position().x()))
self.setStop(self._start) self.setStop(self._start)
elif ev.modifiers() & QtCore.Qt.ControlModifier: elif ev.modifiers() & QtCore.Qt.KeyboardModifier.ControlModifier:
self._drag = "zoom" self._drag = "zoom"
self._offset = QtCore.QPoint(ev.x(), 0) self._offset = QtCore.QPoint(ev.position().x(), 0)
self._rubber = QtWidgets.QRubberBand( self._rubber = QtWidgets.QRubberBand(
QtWidgets.QRubberBand.Rectangle, self) QtWidgets.QRubberBand.Rectangle, self)
self._rubber.setGeometry(QtCore.QRect( self._rubber.setGeometry(QtCore.QRect(
self._offset, QtCore.QPoint(ev.x(), self.height() - 1))) self._offset, QtCore.QPoint(ev.position().x(), self.height() - 1)))
self._rubber.show() self._rubber.show()
else: else:
qfm = QtGui.QFontMetrics(self.font()) qfm = QtGui.QFontMetrics(self.font())
if ev.y() <= 2.5*qfm.lineSpacing(): if ev.position().y() <= 2.5*qfm.lineSpacing():
self._drag = "axis" self._drag = "axis"
self._offset = ev.x() - self._axisView[0] self._offset = ev.position().x() - self._axisView[0]
# testing should match inverse drawing order for start/stop # testing should match inverse drawing order for start/stop
elif abs(self._axisToPixel(self._stop) - elif abs(self._axisToPixel(self._stop) -
ev.x()) < qfm.lineSpacing()/2: ev.position().x()) < qfm.lineSpacing()/2:
self._drag = "stop" self._drag = "stop"
self._offset = ev.x() - self._axisToPixel(self._stop) self._offset = ev.position().x() - self._axisToPixel(self._stop)
elif abs(self._axisToPixel(self._start) - elif abs(self._axisToPixel(self._start) -
ev.x()) < qfm.lineSpacing()/2: ev.position().x()) < qfm.lineSpacing()/2:
self._drag = "start" self._drag = "start"
self._offset = ev.x() - self._axisToPixel(self._start) self._offset = ev.position().x() - self._axisToPixel(self._start)
else: else:
self._drag = "both" self._drag = "both"
self._offset = (ev.x() - self._axisToPixel(self._start), self._offset = (ev.position().x() - self._axisToPixel(self._start),
ev.x() - self._axisToPixel(self._stop)) ev.position().x() - self._axisToPixel(self._stop))
def mouseMoveEvent(self, ev): def mouseMoveEvent(self, ev):
if not self._drag: if not self._drag:
ev.ignore() ev.ignore()
return return
if self._drag == "select": if self._drag == "select":
self.setStop(self._pixelToAxis(ev.x())) self.setStop(self._pixelToAxis(ev.position().x()))
elif self._drag == "zoom": elif self._drag == "zoom":
self._rubber.setGeometry(QtCore.QRect( self._rubber.setGeometry(QtCore.QRect(
self._offset, QtCore.QPoint(ev.x(), self.height() - 1) self._offset, QtCore.QPoint(ev.position().x(), self.height() - 1)
).normalized()) ).normalized())
elif self._drag == "axis": elif self._drag == "axis":
self._setView(ev.x() - self._offset, self._axisView[1]) self._setView(ev.position().x() - self._offset, self._axisView[1])
elif self._drag == "start": elif self._drag == "start":
self.setStart(self._pixelToAxis(ev.x() - self._offset)) self.setStart(self._pixelToAxis(ev.position().x() - self._offset))
elif self._drag == "stop": elif self._drag == "stop":
self.setStop(self._pixelToAxis(ev.x() - self._offset)) self.setStop(self._pixelToAxis(ev.position().x() - self._offset))
elif self._drag == "both": elif self._drag == "both":
self.setStart(self._pixelToAxis(ev.x() - self._offset[0])) self.setStart(self._pixelToAxis(ev.position().x() - self._offset[0]))
self.setStop(self._pixelToAxis(ev.x() - self._offset[1])) self.setStop(self._pixelToAxis(ev.position().x() - self._offset[1]))
def mouseReleaseEvent(self, ev): def mouseReleaseEvent(self, ev):
if self._drag == "zoom": if self._drag == "zoom":
@ -217,10 +217,10 @@ class ScanWidget(QtWidgets.QWidget):
y = round(ev.angleDelta().y()/120.) y = round(ev.angleDelta().y()/120.)
if not y: if not y:
return return
if ev.modifiers() & QtCore.Qt.ShiftModifier: if ev.modifiers() & QtCore.Qt.KeyboardModifier.ShiftModifier:
self.setNum(max(1, self._num + y)) self.setNum(max(1, self._num + y))
else: else:
self._zoom(self.zoomFactor**y, ev.x()) self._zoom(self.zoomFactor**y, ev.position().x())
def resizeEvent(self, ev): def resizeEvent(self, ev):
if not ev.oldSize().isValid() or not ev.oldSize().width(): if not ev.oldSize().isValid() or not ev.oldSize().width():
@ -245,8 +245,8 @@ class ScanWidget(QtWidgets.QWidget):
ticks, prefix, labels = self.ticker(self._pixelToAxis(0), ticks, prefix, labels = self.ticker(self._pixelToAxis(0),
self._pixelToAxis(self.width())) self._pixelToAxis(self.width()))
rect = QtCore.QRect(0, 0, self.width(), lineSpacing) rect = QtCore.QRect(0, 0, self.width(), lineSpacing)
painter.drawText(rect, QtCore.Qt.AlignLeft, prefix) painter.drawText(rect, QtCore.Qt.AlignmentFlag.AlignLeft, prefix)
painter.drawText(rect, QtCore.Qt.AlignRight, self.suffix) painter.drawText(rect, QtCore.Qt.AlignmentFlag.AlignRight, self.suffix)
painter.translate(0, lineSpacing + ascent) painter.translate(0, lineSpacing + ascent)
@ -264,7 +264,7 @@ class ScanWidget(QtWidgets.QWidget):
painter.drawLine(int(p), 0, int(p), int(lineSpacing/2)) painter.drawLine(int(p), 0, int(p), int(lineSpacing/2))
painter.translate(0, int(lineSpacing/2)) painter.translate(0, int(lineSpacing/2))
for x, c in (self._start, QtCore.Qt.blue), (self._stop, QtCore.Qt.red): for x, c in (self._start, QtCore.Qt.GlobalColor.blue), (self._stop, QtCore.Qt.GlobalColor.red):
x = self._axisToPixel(x) x = self._axisToPixel(x)
painter.setPen(c) painter.setPen(c)
painter.setBrush(c) painter.setBrush(c)

View File

@ -1,6 +1,6 @@
import re import re
from math import inf, copysign from math import inf, copysign
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt6 import QtCore, QtGui, QtWidgets
_float_acceptable = re.compile( _float_acceptable = re.compile(
@ -16,8 +16,8 @@ class ScientificSpinBox(QtWidgets.QDoubleSpinBox):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.setGroupSeparatorShown(False) self.setGroupSeparatorShown(False)
self.setInputMethodHints(QtCore.Qt.ImhNone) self.setInputMethodHints(QtCore.Qt.InputMethodHint.ImhNone)
self.setCorrectionMode(self.CorrectToPreviousValue) self.setCorrectionMode(self.CorrectionMode.CorrectToPreviousValue)
# singleStep: resolution for step, buttons, accelerators # singleStep: resolution for step, buttons, accelerators
# decimals: absolute rounding granularity # decimals: absolute rounding granularity
# sigFigs: number of significant digits shown # sigFigs: number of significant digits shown
@ -69,11 +69,11 @@ class ScientificSpinBox(QtWidgets.QDoubleSpinBox):
clean = clean.rsplit(self.suffix(), 1)[0] clean = clean.rsplit(self.suffix(), 1)[0]
try: try:
float(clean) # faster than matching float(clean) # faster than matching
return QtGui.QValidator.Acceptable, text, pos return QtGui.QValidator.State.Acceptable, text, pos
except ValueError: except ValueError:
if re.fullmatch(_float_intermediate, clean): if re.fullmatch(_float_intermediate, clean):
return QtGui.QValidator.Intermediate, text, pos return QtGui.QValidator.State.Intermediate, text, pos
return QtGui.QValidator.Invalid, text, pos return QtGui.QValidator.State.Invalid, text, pos
def stepBy(self, s): def stepBy(self, s):
if abs(s) < 10: # unaccelerated buttons, keys, wheel/trackpad if abs(s) < 10: # unaccelerated buttons, keys, wheel/trackpad

View File

@ -1,7 +1,7 @@
import asyncio import asyncio
import logging import logging
from PyQt5 import QtCore, QtWidgets from PyQt6 import QtCore, QtWidgets
class DoubleClickLineEdit(QtWidgets.QLineEdit): class DoubleClickLineEdit(QtWidgets.QLineEdit):
@ -56,9 +56,9 @@ class WheelFilter(QtCore.QObject):
self.ignore_with_modifier = ignore_with_modifier self.ignore_with_modifier = ignore_with_modifier
def eventFilter(self, obj, event): def eventFilter(self, obj, event):
if event.type() != QtCore.QEvent.Wheel: if event.type() != QtCore.QEvent.Type.Wheel:
return False return False
has_modifier = event.modifiers() != QtCore.Qt.NoModifier has_modifier = event.modifiers() != QtCore.Qt.KeyboardModifier.NoModifier
if has_modifier == self.ignore_with_modifier: if has_modifier == self.ignore_with_modifier:
event.ignore() event.ignore()
return True return True
@ -66,7 +66,7 @@ class WheelFilter(QtCore.QObject):
def disable_scroll_wheel(widget): def disable_scroll_wheel(widget):
widget.setFocusPolicy(QtCore.Qt.StrongFocus) widget.setFocusPolicy(QtCore.Qt.FocusPolicy.StrongFocus)
widget.installEventFilter(WheelFilter(widget)) widget.installEventFilter(WheelFilter(widget))
@ -91,8 +91,8 @@ class LayoutWidget(QtWidgets.QWidget):
async def get_open_file_name(parent, caption, dir, filter): async def get_open_file_name(parent, caption, dir, filter):
"""like QtWidgets.QFileDialog.getOpenFileName(), but a coroutine""" """like QtWidgets.QFileDialog.getOpenFileName(), but a coroutine"""
dialog = QtWidgets.QFileDialog(parent, caption, dir, filter) dialog = QtWidgets.QFileDialog(parent, caption, dir, filter)
dialog.setFileMode(dialog.ExistingFile) dialog.setFileMode(dialog.FileMode.ExistingFile)
dialog.setAcceptMode(dialog.AcceptOpen) dialog.setAcceptMode(dialog.AcceptMode.AcceptOpen)
fut = asyncio.Future() fut = asyncio.Future()
def on_accept(): def on_accept():
@ -124,7 +124,7 @@ async def get_save_file_name(parent, caption, dir, filter, suffix=None):
# http://stackoverflow.com/questions/250890/using-qsortfilterproxymodel-with-a-tree-model # http://stackoverflow.com/questions/250890/using-qsortfilterproxymodel-with-a-tree-model
class QRecursiveFilterProxyModel(QtCore.QSortFilterProxyModel): class QRecursiveFilterProxyModel(QtCore.QSortFilterProxyModel):
def filterAcceptsRow(self, source_row, source_parent): def filterAcceptsRow(self, source_row, source_parent):
regexp = self.filterRegExp() regexp = self.filterRegularExpression()
if not regexp.isEmpty(): if not regexp.isEmpty():
source_index = self.sourceModel().index( source_index = self.sourceModel().index(
source_row, self.filterKeyColumn(), source_parent) source_row, self.filterKeyColumn(), source_parent)
@ -133,6 +133,6 @@ class QRecursiveFilterProxyModel(QtCore.QSortFilterProxyModel):
if self.filterAcceptsRow(i, source_index): if self.filterAcceptsRow(i, source_index):
return True return True
key = self.sourceModel().data(source_index, self.filterRole()) key = self.sourceModel().data(source_index, self.filterRole())
return regexp.indexIn(key) != -1 return regexp.match(key).hasMatch()
return QtCore.QSortFilterProxyModel.filterAcceptsRow( return QtCore.QSortFilterProxyModel.filterAcceptsRow(
self, source_row, source_parent) self, source_row, source_parent)

View File

@ -27,9 +27,9 @@ SOFTWARE.
import math import math
from PyQt5.QtCore import * from PyQt6.QtCore import *
from PyQt5.QtGui import * from PyQt6.QtGui import *
from PyQt5.QtWidgets import * from PyQt6.QtWidgets import *
class QtWaitingSpinner(QWidget): class QtWaitingSpinner(QWidget):
@ -37,7 +37,7 @@ class QtWaitingSpinner(QWidget):
super().__init__() super().__init__()
# WAS IN initialize() # WAS IN initialize()
self._color = QColor(Qt.black) self._color = Qt.GlobalColor.black
self._roundness = 100.0 self._roundness = 100.0
self._minimumTrailOpacity = 3.14159265358979323846 self._minimumTrailOpacity = 3.14159265358979323846
self._trailFadePercentage = 80.0 self._trailFadePercentage = 80.0
@ -54,17 +54,17 @@ class QtWaitingSpinner(QWidget):
self.updateTimer() self.updateTimer()
# END initialize() # END initialize()
self.setAttribute(Qt.WA_TranslucentBackground) self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
def paintEvent(self, QPaintEvent): def paintEvent(self, QPaintEvent):
painter = QPainter(self) painter = QPainter(self)
painter.fillRect(self.rect(), Qt.transparent) painter.fillRect(self.rect(), Qt.GlobalColor.transparent)
painter.setRenderHint(QPainter.Antialiasing, True) painter.setRenderHint(QPainter.RenderHint.Antialiasing, True)
if self._currentCounter >= self._numberOfLines: if self._currentCounter >= self._numberOfLines:
self._currentCounter = 0 self._currentCounter = 0
painter.setPen(Qt.NoPen) painter.setPen(Qt.PenStyle.NoPen)
for i in range(0, self._numberOfLines): for i in range(0, self._numberOfLines):
painter.save() painter.save()
painter.translate(self._innerRadius + self._lineLength, self._innerRadius + self._lineLength) painter.translate(self._innerRadius + self._lineLength, self._innerRadius + self._lineLength)
@ -76,7 +76,7 @@ class QtWaitingSpinner(QWidget):
self._minimumTrailOpacity, self._color) self._minimumTrailOpacity, self._color)
painter.setBrush(color) painter.setBrush(color)
painter.drawRoundedRect(QRect(0, int(-self._lineWidth / 2), self._lineLength, self._lineWidth), self._roundness, painter.drawRoundedRect(QRect(0, int(-self._lineWidth / 2), self._lineLength, self._lineWidth), self._roundness,
self._roundness, Qt.RelativeSize) self._roundness, Qt.SizeMode.RelativeSize)
painter.restore() painter.restore()
def start(self): def start(self):
@ -136,7 +136,7 @@ class QtWaitingSpinner(QWidget):
def setRoundness(self, roundness): def setRoundness(self, roundness):
self._roundness = max(0.0, min(100.0, roundness)) self._roundness = max(0.0, min(100.0, roundness))
def setColor(self, color=Qt.black): def setColor(self, color=Qt.GlobalColor.black):
self._color = QColor(color) self._color = QColor(color)
def setRevolutionsPerSecond(self, revolutionsPerSecond): def setRevolutionsPerSecond(self, revolutionsPerSecond):

View File

@ -37,7 +37,7 @@ mock_modules = ["artiq.gui.waitingspinnerwidget",
"artiq.dashboard.waveform", "artiq.dashboard.waveform",
"artiq.dashboard.interactive_args", "artiq.dashboard.interactive_args",
"qasync", "pyqtgraph", "matplotlib", "lmdb", "qasync", "pyqtgraph", "matplotlib", "lmdb",
"numpy", "dateutil", "dateutil.parser", "prettytable", "PyQt5", "numpy", "dateutil", "dateutil.parser", "prettytable", "PyQt6",
"h5py", "serial", "scipy", "scipy.interpolate", "h5py", "serial", "scipy", "scipy.interpolate",
"llvmlite", "Levenshtein", "pythonparser", "llvmlite", "Levenshtein", "pythonparser",
"sipyco", "sipyco.pc_rpc", "sipyco.sync_struct", "sipyco", "sipyco.pc_rpc", "sipyco.sync_struct",

View File

@ -16,7 +16,7 @@ ARTIQ and its dependencies are available in the form of Nix packages (for Linux)
ARTIQ is supported by M-Labs and developed openly. Components, features, fixes, improvements, and extensions are often `funded <https://m-labs.hk/experiment-control/funding/>`_ by and developed for the partnering research groups. ARTIQ is supported by M-Labs and developed openly. Components, features, fixes, improvements, and extensions are often `funded <https://m-labs.hk/experiment-control/funding/>`_ by and developed for the partnering research groups.
Core technologies employed include `Python <https://www.python.org/>`_, `Migen <https://github.com/m-labs/migen>`_, `Migen-AXI <https://github.com/peteut/migen-axi>`_, `Rust <https://www.rust-lang.org/>`_, `MiSoC <https://github.com/m-labs/misoc>`_/`VexRiscv <https://github.com/SpinalHDL/VexRiscv>`_, `LLVM <https://llvm.org/>`_/`llvmlite <https://github.com/numba/llvmlite>`_, and `Qt5 <https://www.qt.io/>`_. Core technologies employed include `Python <https://www.python.org/>`_, `Migen <https://github.com/m-labs/migen>`_, `Migen-AXI <https://github.com/peteut/migen-axi>`_, `Rust <https://www.rust-lang.org/>`_, `MiSoC <https://github.com/m-labs/misoc>`_/`VexRiscv <https://github.com/SpinalHDL/VexRiscv>`_, `LLVM <https://llvm.org/>`_/`llvmlite <https://github.com/numba/llvmlite>`_, and `Qt6 <https://www.qt.io/>`_.
| Website: https://m-labs.hk/experiment-control/artiq | Website: https://m-labs.hk/experiment-control/artiq
| (US-hosted mirror: https://m-labs-intl.com/experiment-control/artiq) | (US-hosted mirror: https://m-labs-intl.com/experiment-control/artiq)

View File

@ -76,7 +76,7 @@
rev = "v${version}"; rev = "v${version}";
sha256 = "sha256-DAzmobw+c29Pt/URGO3bWXHBxgu9bDHhdTUBE9QJDe4="; sha256 = "sha256-DAzmobw+c29Pt/URGO3bWXHBxgu9bDHhdTUBE9QJDe4=";
}; };
propagatedBuildInputs = [ pkgs.python3Packages.pyqt5 ]; propagatedBuildInputs = [ pkgs.python3Packages.pyqt6 ];
nativeCheckInputs = [ pkgs.python3Packages.pytest-runner pkgs.python3Packages.pytestCheckHook ]; nativeCheckInputs = [ pkgs.python3Packages.pytest-runner pkgs.python3Packages.pytestCheckHook ];
disabledTestPaths = [ "tests/test_qeventloop.py" ]; disabledTestPaths = [ "tests/test_qeventloop.py" ];
}; };
@ -132,10 +132,10 @@
export VERSIONEER_REV=${artiqRev} export VERSIONEER_REV=${artiqRev}
''; '';
nativeBuildInputs = [ pkgs.qt5.wrapQtAppsHook ]; nativeBuildInputs = [ pkgs.qt6.wrapQtAppsHook ];
# keep llvm_x and lld_x in sync with llvmlite # keep llvm_x and lld_x in sync with llvmlite
propagatedBuildInputs = [ pkgs.llvm_15 pkgs.lld_15 sipyco.packages.x86_64-linux.sipyco pythonparser llvmlite-new pkgs.qt5.qtsvg artiq-comtools.packages.x86_64-linux.artiq-comtools ] propagatedBuildInputs = [ pkgs.llvm_15 pkgs.lld_15 sipyco.packages.x86_64-linux.sipyco pythonparser llvmlite-new pkgs.qt6.qtsvg artiq-comtools.packages.x86_64-linux.artiq-comtools ]
++ (with pkgs.python3Packages; [ pyqtgraph pygit2 numpy dateutil scipy prettytable pyserial levenshtein h5py pyqt5 qasync tqdm lmdb jsonschema ]); ++ (with pkgs.python3Packages; [ pyqtgraph pygit2 numpy dateutil scipy prettytable pyserial levenshtein h5py pyqt6 qasync tqdm lmdb jsonschema ]);
dontWrapQtApps = true; dontWrapQtApps = true;
postFixup = '' postFixup = ''
@ -413,8 +413,8 @@
]; ];
shellHook = '' shellHook = ''
export LIBARTIQ_SUPPORT=`libartiq-support` export LIBARTIQ_SUPPORT=`libartiq-support`
export QT_PLUGIN_PATH=${pkgs.qt5.qtbase}/${pkgs.qt5.qtbase.dev.qtPluginPrefix}:${pkgs.qt5.qtsvg.bin}/${pkgs.qt5.qtbase.dev.qtPluginPrefix} export QT_PLUGIN_PATH=${pkgs.qt6.qtbase}/${pkgs.qt6.qtbase.dev.qtPluginPrefix}:${pkgs.qt6.qtsvg}/${pkgs.qt6.qtbase.dev.qtPluginPrefix}
export QML2_IMPORT_PATH=${pkgs.qt5.qtbase}/${pkgs.qt5.qtbase.dev.qtQmlPrefix} export QML2_IMPORT_PATH=${pkgs.qt6.qtbase}/${pkgs.qt6.qtbase.dev.qtQmlPrefix}
export PYTHONPATH=`git rev-parse --show-toplevel`:$PYTHONPATH export PYTHONPATH=`git rev-parse --show-toplevel`:$PYTHONPATH
''; '';
}; };

View File

@ -10,7 +10,7 @@ if sys.version_info[:2] < (3, 7):
raise Exception("You need Python 3.7+") raise Exception("You need Python 3.7+")
# Depends on PyQt5, but setuptools cannot check for it. # Depends on PyQt6, but setuptools cannot check for it.
requirements = [ requirements = [
"numpy", "scipy", "numpy", "scipy",
"python-dateutil", "prettytable", "h5py", "lmdb", "python-dateutil", "prettytable", "h5py", "lmdb",