Skip to content

Commit

Permalink
Use (Py)Qt6 instead of Qt5
Browse files Browse the repository at this point in the history
If necessary, this could be made to be backwards-compatible to PyQt5
quite straightforwardly by monkey-patching in the respective constants,
such that Qt 5 support could cleanly be dropped once it is no longer
necessary.

For now, Qt 6 it is.
  • Loading branch information
dnadlinger committed Sep 17, 2023
1 parent 9f28126 commit fa1e5d9
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 29 deletions.
44 changes: 22 additions & 22 deletions ndscan/dashboard/argument_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import logging
import os
from typing import Any, Dict, List, Optional, Tuple
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt6 import QtCore, QtGui, QtWidgets
from artiq.dashboard.experiments import _WheelFilter
from artiq.gui.entries import procdesc_to_entry
from artiq.gui.fuzzy_select import FuzzySelectWidget
Expand Down Expand Up @@ -128,13 +128,13 @@ def __init__(self, manager, dock, expurl):
set_resize_mode = self.header().setSectionResizeMode
else:
set_resize_mode = self.header().setResizeMode
set_resize_mode(0, QtWidgets.QHeaderView.ResizeToContents)
set_resize_mode(1, QtWidgets.QHeaderView.Stretch)
set_resize_mode(2, QtWidgets.QHeaderView.ResizeToContents)
set_resize_mode(0, QtWidgets.QHeaderView.ResizeMode.ResizeToContents)
set_resize_mode(1, QtWidgets.QHeaderView.ResizeMode.Stretch)
set_resize_mode(2, QtWidgets.QHeaderView.ResizeMode.ResizeToContents)
self.header().setVisible(False)
self.setSelectionMode(self.NoSelection)
self.setHorizontalScrollMode(self.ScrollPerPixel)
self.setVerticalScrollMode(self.ScrollPerPixel)
self.setSelectionMode(self.SelectionMode.NoSelection)
self.setHorizontalScrollMode(self.ScrollMode.ScrollPerPixel)
self.setVerticalScrollMode(self.ScrollMode.ScrollPerPixel)

self.setStyleSheet("QTreeWidget {background: " +
self.palette().midlight().color().name() + " ;}")
Expand Down Expand Up @@ -164,9 +164,9 @@ def icon_path(name):
self._randomise_scan_icon = QtGui.QIcon(
icon_path("media-playlist-shuffle-32.svg"))
self._default_value_icon = self.style().standardIcon(
QtWidgets.QStyle.SP_BrowserReload)
QtWidgets.QStyle.StandardPixmap.SP_BrowserReload)
self._disable_scans_icon = self.style().standardIcon(
QtWidgets.QStyle.SP_DialogResetButton)
QtWidgets.QStyle.StandardPixmap.SP_DialogResetButton)

self._arguments = self.manager.get_submission_arguments(self.expurl)
ndscan_params, vanilla_args = _try_extract_ndscan_params(self._arguments)
Expand Down Expand Up @@ -222,13 +222,13 @@ def icon_path(name):

load_hdf5 = QtWidgets.QPushButton("Load HDF5")
load_hdf5.setIcon(QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_DialogOpenButton))
QtWidgets.QStyle.StandardPixmap.SP_DialogOpenButton))
load_hdf5.clicked.connect(dock._load_hdf5_clicked)

disable_scans = QtWidgets.QPushButton("Disable all scans")
disable_scans.setIcon(self._disable_scans_icon)
disable_scans.clicked.connect(self.disable_all_scans)
disable_scans.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_R)
disable_scans.setShortcut("Ctrl+R")

buttons = LayoutWidget()
buttons.addWidget(recompute_arguments, col=1)
Expand Down Expand Up @@ -315,7 +315,7 @@ def add_item(widget_item):
reset_default = QtWidgets.QToolButton()
reset_default.setToolTip("Reset parameter to default value")
reset_default.setIcon(QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.SP_BrowserReload))
QtWidgets.QStyle.StandardPixmap.SP_BrowserReload))
reset_default.clicked.connect(partial(self._reset_entry_to_default, fqn, path))
buttons.addWidget(reset_default, col=0)

Expand Down Expand Up @@ -383,10 +383,10 @@ def _make_vanilla_argument_item(self, name, argument):
def _make_line_separator(self):
f = QtWidgets.QFrame(self)
f.setMinimumHeight(15)
f.setFrameShape(QtWidgets.QFrame.HLine)
f.setFrameShadow(QtWidgets.QFrame.Sunken)
f.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
QtWidgets.QSizePolicy.Preferred)
f.setFrameShape(QtWidgets.QFrame.Shape.HLine)
f.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
f.setSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding,
QtWidgets.QSizePolicy.Policy.Preferred)

wi = QtWidgets.QTreeWidgetItem()
self.addTopLevelItem(wi)
Expand All @@ -400,7 +400,7 @@ def _make_override_item(self, fqn, path):
self._override_items[(fqn, path)] = items
self._set_save_timer()

# Make sure layout is updated to accomodate new row; without this, the
# Make sure layout is updated to accommodate new row; without this, the
# new item and the add prompt button overlap on Qt 5.6.2/Win64 until
# the dock is resized for the first time.
geom = self.geometry()
Expand All @@ -416,7 +416,7 @@ def _make_add_override_prompt_item(self):
self._add_override_button = QtWidgets.QToolButton()
self._add_override_button.setIcon(self._add_override_icon)
self._add_override_button.clicked.connect(self._set_override_line_active)
self._add_override_button.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_T)
self._add_override_button.setShortcut("Ctrl+T")
left.addWidget(self._add_override_button, 0, 0)

self._add_override_prompt_label = QtWidgets.QLabel("Add parameter:")
Expand Down Expand Up @@ -750,10 +750,10 @@ def __init__(self, entry: OverrideEntry):

def _make_divider(self):
f = QtWidgets.QFrame()
f.setFrameShape(QtWidgets.QFrame.VLine)
f.setFrameShadow(QtWidgets.QFrame.Sunken)
f.setSizePolicy(QtWidgets.QSizePolicy.Preferred,
QtWidgets.QSizePolicy.Expanding)
f.setFrameShape(QtWidgets.QFrame.Shape.VLine)
f.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
f.setSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred,
QtWidgets.QSizePolicy.Policy.Expanding)
return f

def _make_spin_box(self):
Expand Down
4 changes: 2 additions & 2 deletions ndscan/plots/image_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging
import numpy as np
import pyqtgraph
from qasync import QtWidgets, QtCore
from qasync import QtCore, QtGui
from typing import Dict, Optional

from . import colormaps
Expand Down Expand Up @@ -254,7 +254,7 @@ def set_both():
action.triggered.connect(set_both)
builder.ensure_separator()

self.channel_menu_group = QtWidgets.QActionGroup(self)
self.channel_menu_group = QtGui.QActionGroup(self)
for name in self.data_names:
action = builder.append_action(name)
action.setCheckable(True)
Expand Down
48 changes: 44 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ h5py = "^3.9.0"
pyqtgraph = "^0.13.3"
pyqt6 = "^6.5.2"
qasync = "^0.24.0"
artiq = {git = "https://github.com/m-labs/artiq.git", rev = "8dc6902c2"}
artiq = {git = "https://github.com/dnadlinger/artiq.git", branch = "qt6"}
sipyco = {git = "https://github.com/m-labs/sipyco.git"}
oitg = {git = "https://github.com/oxfordiontrapgroup/oitg.git"}

Expand Down

0 comments on commit fa1e5d9

Please sign in to comment.