mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 11:41:49 +02:00
fix: use SafeSlot instead of Slot
This commit is contained in:
@ -1,12 +1,13 @@
|
|||||||
# Copyright (C) 2022 The Qt Company Ltd.
|
# Copyright (C) 2022 The Qt Company Ltd.
|
||||||
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||||
|
|
||||||
from qtpy.QtCore import Slot
|
|
||||||
from qtpy.QtDesigner import QExtensionFactory, QPyDesignerTaskMenuExtension
|
from qtpy.QtDesigner import QExtensionFactory, QPyDesignerTaskMenuExtension
|
||||||
from qtpy.QtGui import QAction
|
from qtpy.QtGui import QAction
|
||||||
from qtpy.QtWidgets import QDialog, QDialogButtonBox, QVBoxLayout
|
from qtpy.QtWidgets import QDialog, QDialogButtonBox, QVBoxLayout
|
||||||
from tictactoe import TicTacToe
|
from tictactoe import TicTacToe
|
||||||
|
|
||||||
|
from bec_widgets.qt_utils.error_popups import SafeSlot as Slot
|
||||||
|
|
||||||
|
|
||||||
class TicTacToeDialog(QDialog): # pragma: no cover
|
class TicTacToeDialog(QDialog): # pragma: no cover
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
|
@ -34,7 +34,7 @@ class WarningPopupUtility(QObject):
|
|||||||
Utility class to show warning popups in the application.
|
Utility class to show warning popups in the application.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@Slot(str, str, str, QWidget)
|
@SafeSlot(str, str, str, QWidget)
|
||||||
def show_warning_message(self, title, message, detailed_text, widget):
|
def show_warning_message(self, title, message, detailed_text, widget):
|
||||||
msg = QMessageBox(widget)
|
msg = QMessageBox(widget)
|
||||||
msg.setIcon(QMessageBox.Warning)
|
msg.setIcon(QMessageBox.Warning)
|
||||||
@ -75,7 +75,7 @@ class _ErrorPopupUtility(QObject):
|
|||||||
self._initialized = True
|
self._initialized = True
|
||||||
sys.excepthook = self.custom_exception_hook
|
sys.excepthook = self.custom_exception_hook
|
||||||
|
|
||||||
@Slot(str, str, QWidget)
|
@SafeSlot(str, str, QWidget)
|
||||||
def show_error_message(self, title, message, widget):
|
def show_error_message(self, title, message, widget):
|
||||||
detailed_text = self.format_traceback(message)
|
detailed_text = self.format_traceback(message)
|
||||||
error_message = self.parse_error_message(detailed_text)
|
error_message = self.parse_error_message(detailed_text)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from qtpy.QtCore import Slot
|
|
||||||
from qtpy.QtWidgets import QDialog, QDialogButtonBox, QHBoxLayout, QPushButton, QVBoxLayout, QWidget
|
from qtpy.QtWidgets import QDialog, QDialogButtonBox, QHBoxLayout, QPushButton, QVBoxLayout, QWidget
|
||||||
|
|
||||||
|
from bec_widgets.qt_utils.error_popups import SafeSlot as Slot
|
||||||
|
|
||||||
|
|
||||||
class SettingWidget(QWidget):
|
class SettingWidget(QWidget):
|
||||||
"""
|
"""
|
||||||
|
@ -10,11 +10,11 @@ import yaml
|
|||||||
from bec_lib.utils.import_utils import lazy_import_from
|
from bec_lib.utils.import_utils import lazy_import_from
|
||||||
from pydantic import BaseModel, Field, field_validator
|
from pydantic import BaseModel, Field, field_validator
|
||||||
from qtpy.QtCore import QObject, QRunnable, QThreadPool, Signal
|
from qtpy.QtCore import QObject, QRunnable, QThreadPool, Signal
|
||||||
from qtpy.QtCore import Slot as pyqtSlot
|
|
||||||
from qtpy.QtWidgets import QApplication
|
from qtpy.QtWidgets import QApplication
|
||||||
|
|
||||||
from bec_widgets.cli.rpc_register import RPCRegister
|
from bec_widgets.cli.rpc_register import RPCRegister
|
||||||
from bec_widgets.qt_utils.error_popups import ErrorPopupUtility
|
from bec_widgets.qt_utils.error_popups import ErrorPopupUtility
|
||||||
|
from bec_widgets.qt_utils.error_popups import SafeSlot as pyqtSlot
|
||||||
from bec_widgets.utils.yaml_dialog import load_yaml, load_yaml_gui, save_yaml, save_yaml_gui
|
from bec_widgets.utils.yaml_dialog import load_yaml, load_yaml_gui, save_yaml, save_yaml_gui
|
||||||
|
|
||||||
BECDispatcher = lazy_import_from("bec_widgets.utils.bec_dispatcher", ("BECDispatcher",))
|
BECDispatcher = lazy_import_from("bec_widgets.utils.bec_dispatcher", ("BECDispatcher",))
|
||||||
|
@ -18,10 +18,11 @@ import pyte
|
|||||||
from qtpy import QtCore, QtGui, QtWidgets
|
from qtpy import QtCore, QtGui, QtWidgets
|
||||||
from qtpy.QtCore import QSize, QSocketNotifier, Qt
|
from qtpy.QtCore import QSize, QSocketNotifier, Qt
|
||||||
from qtpy.QtCore import Signal as pyqtSignal
|
from qtpy.QtCore import Signal as pyqtSignal
|
||||||
from qtpy.QtCore import Slot as pyqtSlot
|
|
||||||
from qtpy.QtGui import QClipboard, QTextCursor
|
from qtpy.QtGui import QClipboard, QTextCursor
|
||||||
from qtpy.QtWidgets import QApplication, QHBoxLayout, QScrollBar, QSizePolicy
|
from qtpy.QtWidgets import QApplication, QHBoxLayout, QScrollBar, QSizePolicy
|
||||||
|
|
||||||
|
from bec_widgets.qt_utils.error_popups import SafeSlot as Slot
|
||||||
|
|
||||||
ansi_colors = {
|
ansi_colors = {
|
||||||
"black": "#000000",
|
"black": "#000000",
|
||||||
"red": "#CD0000",
|
"red": "#CD0000",
|
||||||
@ -289,7 +290,7 @@ class _TerminalWidget(QtWidgets.QPlainTextEdit):
|
|||||||
old["value"] = value
|
old["value"] = value
|
||||||
self.dataReady(self.backend.screen, reset_scroll=False)
|
self.dataReady(self.backend.screen, reset_scroll=False)
|
||||||
|
|
||||||
@pyqtSlot(object)
|
@Slot(object)
|
||||||
def keyPressEvent(self, event):
|
def keyPressEvent(self, event):
|
||||||
"""
|
"""
|
||||||
Redirect all keystrokes to the terminal process.
|
Redirect all keystrokes to the terminal process.
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from qtpy.QtCore import Slot
|
|
||||||
from qtpy.QtWidgets import QVBoxLayout
|
from qtpy.QtWidgets import QVBoxLayout
|
||||||
|
|
||||||
|
from bec_widgets.qt_utils.error_popups import SafeSlot as Slot
|
||||||
from bec_widgets.qt_utils.settings_dialog import SettingWidget
|
from bec_widgets.qt_utils.settings_dialog import SettingWidget
|
||||||
from bec_widgets.utils import UILoader
|
from bec_widgets.utils import UILoader
|
||||||
from bec_widgets.utils.widget_io import WidgetIO
|
from bec_widgets.utils.widget_io import WidgetIO
|
||||||
|
@ -7,9 +7,9 @@ import numpy as np
|
|||||||
from bec_lib.endpoints import MessageEndpoints
|
from bec_lib.endpoints import MessageEndpoints
|
||||||
from pydantic import BaseModel, Field, ValidationError
|
from pydantic import BaseModel, Field, ValidationError
|
||||||
from qtpy.QtCore import QThread
|
from qtpy.QtCore import QThread
|
||||||
from qtpy.QtCore import Slot as pyqtSlot
|
|
||||||
from qtpy.QtWidgets import QWidget
|
from qtpy.QtWidgets import QWidget
|
||||||
|
|
||||||
|
from bec_widgets.qt_utils.error_popups import SafeSlot as Slot
|
||||||
from bec_widgets.utils import EntryValidator
|
from bec_widgets.utils import EntryValidator
|
||||||
from bec_widgets.widgets.figure.plots.image.image_item import BECImageItem, ImageItemConfig
|
from bec_widgets.widgets.figure.plots.image.image_item import BECImageItem, ImageItemConfig
|
||||||
from bec_widgets.widgets.figure.plots.image.image_processor import (
|
from bec_widgets.widgets.figure.plots.image.image_processor import (
|
||||||
@ -500,7 +500,7 @@ class BECImageShow(BECPlotBase):
|
|||||||
self.update_image(device, data)
|
self.update_image(device, data)
|
||||||
self.update_vrange(device, self.processor.config.stats)
|
self.update_vrange(device, self.processor.config.stats)
|
||||||
|
|
||||||
@pyqtSlot(dict)
|
@Slot(dict)
|
||||||
def on_image_update(self, msg: dict):
|
def on_image_update(self, msg: dict):
|
||||||
"""
|
"""
|
||||||
Update the image of the device monitor from bec.
|
Update the image of the device monitor from bec.
|
||||||
@ -514,7 +514,7 @@ class BECImageShow(BECPlotBase):
|
|||||||
image.raw_data = data
|
image.raw_data = data
|
||||||
self.process_image(device, image, data)
|
self.process_image(device, image, data)
|
||||||
|
|
||||||
@pyqtSlot(str, np.ndarray)
|
@Slot(str, np.ndarray)
|
||||||
def update_image(self, device: str, data: np.ndarray):
|
def update_image(self, device: str, data: np.ndarray):
|
||||||
"""
|
"""
|
||||||
Update the image of the device monitor.
|
Update the image of the device monitor.
|
||||||
@ -526,7 +526,7 @@ class BECImageShow(BECPlotBase):
|
|||||||
image_to_update = self._images["device_monitor_2d"][device]
|
image_to_update = self._images["device_monitor_2d"][device]
|
||||||
image_to_update.updateImage(data, autoLevels=image_to_update.config.autorange)
|
image_to_update.updateImage(data, autoLevels=image_to_update.config.autorange)
|
||||||
|
|
||||||
@pyqtSlot(str, ImageStats)
|
@Slot(str, ImageStats)
|
||||||
def update_vrange(self, device: str, stats: ImageStats):
|
def update_vrange(self, device: str, stats: ImageStats):
|
||||||
"""
|
"""
|
||||||
Update the scaling of the image.
|
Update the scaling of the image.
|
||||||
|
@ -10,9 +10,9 @@ from pydantic import Field, ValidationError, field_validator
|
|||||||
from pydantic_core import PydanticCustomError
|
from pydantic_core import PydanticCustomError
|
||||||
from qtpy import QtCore, QtGui
|
from qtpy import QtCore, QtGui
|
||||||
from qtpy.QtCore import Signal as pyqtSignal
|
from qtpy.QtCore import Signal as pyqtSignal
|
||||||
from qtpy.QtCore import Slot
|
|
||||||
from qtpy.QtWidgets import QWidget
|
from qtpy.QtWidgets import QWidget
|
||||||
|
|
||||||
|
from bec_widgets.qt_utils.error_popups import SafeSlot as Slot
|
||||||
from bec_widgets.utils import Colors, EntryValidator
|
from bec_widgets.utils import Colors, EntryValidator
|
||||||
from bec_widgets.widgets.figure.plots.plot_base import BECPlotBase, SubplotConfig
|
from bec_widgets.widgets.figure.plots.plot_base import BECPlotBase, SubplotConfig
|
||||||
from bec_widgets.widgets.figure.plots.waveform.waveform import Signal, SignalData
|
from bec_widgets.widgets.figure.plots.waveform.waveform import Signal, SignalData
|
||||||
@ -444,7 +444,7 @@ class BECMotorMap(BECPlotBase):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
@Slot()
|
@Slot()
|
||||||
def _update_plot(self):
|
def _update_plot(self, _=None):
|
||||||
"""Update the motor map plot."""
|
"""Update the motor map plot."""
|
||||||
# If the number of points exceeds max_points, delete the oldest points
|
# If the number of points exceeds max_points, delete the oldest points
|
||||||
if len(self.database_buffer["x"]) > self.config.max_points:
|
if len(self.database_buffer["x"]) > self.config.max_points:
|
||||||
|
@ -11,9 +11,9 @@ from bec_lib.endpoints import MessageEndpoints
|
|||||||
from pydantic import Field, ValidationError, field_validator
|
from pydantic import Field, ValidationError, field_validator
|
||||||
from pyqtgraph.exporters import MatplotlibExporter
|
from pyqtgraph.exporters import MatplotlibExporter
|
||||||
from qtpy.QtCore import Signal as pyqtSignal
|
from qtpy.QtCore import Signal as pyqtSignal
|
||||||
from qtpy.QtCore import Slot as pyqtSlot
|
|
||||||
from qtpy.QtWidgets import QWidget
|
from qtpy.QtWidgets import QWidget
|
||||||
|
|
||||||
|
from bec_widgets.qt_utils.error_popups import SafeSlot as Slot
|
||||||
from bec_widgets.utils import Colors, EntryValidator
|
from bec_widgets.utils import Colors, EntryValidator
|
||||||
from bec_widgets.widgets.figure.plots.plot_base import BECPlotBase, SubplotConfig
|
from bec_widgets.widgets.figure.plots.plot_base import BECPlotBase, SubplotConfig
|
||||||
from bec_widgets.widgets.figure.plots.waveform.waveform_curve import (
|
from bec_widgets.widgets.figure.plots.waveform.waveform_curve import (
|
||||||
@ -391,7 +391,7 @@ class BECWaveform(BECPlotBase):
|
|||||||
self.async_signal_update.emit()
|
self.async_signal_update.emit()
|
||||||
self.scan_signal_update.emit()
|
self.scan_signal_update.emit()
|
||||||
|
|
||||||
@pyqtSlot()
|
@Slot()
|
||||||
def auto_range(self):
|
def auto_range(self):
|
||||||
self.plot_item.autoRange()
|
self.plot_item.autoRange()
|
||||||
|
|
||||||
@ -408,7 +408,7 @@ class BECWaveform(BECPlotBase):
|
|||||||
"""
|
"""
|
||||||
self.plot_item.enableAutoRange(axis, enabled)
|
self.plot_item.enableAutoRange(axis, enabled)
|
||||||
|
|
||||||
@pyqtSlot()
|
@Slot()
|
||||||
def auto_range(self):
|
def auto_range(self):
|
||||||
self.plot_item.autoRange()
|
self.plot_item.autoRange()
|
||||||
|
|
||||||
@ -642,7 +642,7 @@ class BECWaveform(BECPlotBase):
|
|||||||
self.refresh_dap()
|
self.refresh_dap()
|
||||||
return curve
|
return curve
|
||||||
|
|
||||||
@pyqtSlot()
|
@Slot()
|
||||||
def get_dap_params(self) -> dict:
|
def get_dap_params(self) -> dict:
|
||||||
"""
|
"""
|
||||||
Get the DAP parameters of all DAP curves.
|
Get the DAP parameters of all DAP curves.
|
||||||
@ -655,7 +655,7 @@ class BECWaveform(BECPlotBase):
|
|||||||
params[curve_id] = curve.dap_params
|
params[curve_id] = curve.dap_params
|
||||||
return params
|
return params
|
||||||
|
|
||||||
@pyqtSlot()
|
@Slot()
|
||||||
def get_dap_summary(self) -> dict:
|
def get_dap_summary(self) -> dict:
|
||||||
"""
|
"""
|
||||||
Get the DAP summary of all DAP curves.
|
Get the DAP summary of all DAP curves.
|
||||||
@ -921,7 +921,7 @@ class BECWaveform(BECPlotBase):
|
|||||||
else:
|
else:
|
||||||
raise IndexError(f"Curve order {N} out of range.")
|
raise IndexError(f"Curve order {N} out of range.")
|
||||||
|
|
||||||
@pyqtSlot(dict)
|
@Slot(dict)
|
||||||
def on_scan_status(self, msg):
|
def on_scan_status(self, msg):
|
||||||
"""
|
"""
|
||||||
Handle the scan status message.
|
Handle the scan status message.
|
||||||
@ -945,7 +945,7 @@ class BECWaveform(BECPlotBase):
|
|||||||
for curve_id, curve in self._curves_data["async"].items():
|
for curve_id, curve in self._curves_data["async"].items():
|
||||||
self.setup_async(curve.config.signals.y.name)
|
self.setup_async(curve.config.signals.y.name)
|
||||||
|
|
||||||
@pyqtSlot(dict, dict)
|
@Slot(dict, dict)
|
||||||
def on_scan_segment(self, msg: dict, metadata: dict):
|
def on_scan_segment(self, msg: dict, metadata: dict):
|
||||||
"""
|
"""
|
||||||
Handle new scan segments and saves data to a dictionary. Linked through bec_dispatcher.
|
Handle new scan segments and saves data to a dictionary. Linked through bec_dispatcher.
|
||||||
@ -1004,7 +1004,7 @@ class BECWaveform(BECPlotBase):
|
|||||||
self.update_dap, MessageEndpoints.dap_response(f"{new_scan_id}-{self.gui_id}")
|
self.update_dap, MessageEndpoints.dap_response(f"{new_scan_id}-{self.gui_id}")
|
||||||
)
|
)
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@Slot(str)
|
||||||
def setup_async(self, device: str):
|
def setup_async(self, device: str):
|
||||||
self.bec_dispatcher.disconnect_slot(
|
self.bec_dispatcher.disconnect_slot(
|
||||||
self.on_async_readback, MessageEndpoints.device_async_readback(self.old_scan_id, device)
|
self.on_async_readback, MessageEndpoints.device_async_readback(self.old_scan_id, device)
|
||||||
@ -1020,8 +1020,8 @@ class BECWaveform(BECPlotBase):
|
|||||||
from_start=True,
|
from_start=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@pyqtSlot()
|
@Slot()
|
||||||
def refresh_dap(self):
|
def refresh_dap(self, _=None):
|
||||||
"""
|
"""
|
||||||
Refresh the DAP curves with the latest data from the DAP model MessageEndpoints.dap_response().
|
Refresh the DAP curves with the latest data from the DAP model MessageEndpoints.dap_response().
|
||||||
"""
|
"""
|
||||||
@ -1069,7 +1069,7 @@ class BECWaveform(BECPlotBase):
|
|||||||
)
|
)
|
||||||
self.client.connector.set_and_publish(MessageEndpoints.dap_request(), msg)
|
self.client.connector.set_and_publish(MessageEndpoints.dap_request(), msg)
|
||||||
|
|
||||||
@pyqtSlot(dict, dict)
|
@Slot(dict, dict)
|
||||||
def update_dap(self, msg, metadata):
|
def update_dap(self, msg, metadata):
|
||||||
self.msg = msg
|
self.msg = msg
|
||||||
scan_id, x_name, x_entry, y_name, y_entry = msg["dap_request"].content["config"]["args"]
|
scan_id, x_name, x_entry, y_name, y_entry = msg["dap_request"].content["config"]["args"]
|
||||||
@ -1089,7 +1089,7 @@ class BECWaveform(BECPlotBase):
|
|||||||
self.dap_summary_update.emit(curve.dap_summary)
|
self.dap_summary_update.emit(curve.dap_summary)
|
||||||
break
|
break
|
||||||
|
|
||||||
@pyqtSlot(dict, dict)
|
@Slot(dict, dict)
|
||||||
def on_async_readback(self, msg, metadata):
|
def on_async_readback(self, msg, metadata):
|
||||||
"""
|
"""
|
||||||
Get async data readback.
|
Get async data readback.
|
||||||
@ -1127,7 +1127,7 @@ class BECWaveform(BECPlotBase):
|
|||||||
else:
|
else:
|
||||||
curve.setData(data_plot)
|
curve.setData(data_plot)
|
||||||
|
|
||||||
@pyqtSlot()
|
@Slot()
|
||||||
def replot_async_curve(self):
|
def replot_async_curve(self):
|
||||||
try:
|
try:
|
||||||
data = self.scan_item.async_data
|
data = self.scan_item.async_data
|
||||||
@ -1152,8 +1152,8 @@ class BECWaveform(BECPlotBase):
|
|||||||
else:
|
else:
|
||||||
curve.setData(data_x, data_y)
|
curve.setData(data_x, data_y)
|
||||||
|
|
||||||
@pyqtSlot()
|
@Slot()
|
||||||
def _update_scan_curves(self):
|
def _update_scan_curves(self, _=None):
|
||||||
"""
|
"""
|
||||||
Update the scan curves with the data from the scan segment.
|
Update the scan curves with the data from the scan segment.
|
||||||
"""
|
"""
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from qtpy.QtCore import Slot
|
|
||||||
from qtpy.QtWidgets import QVBoxLayout
|
from qtpy.QtWidgets import QVBoxLayout
|
||||||
|
|
||||||
|
from bec_widgets.qt_utils.error_popups import SafeSlot as Slot
|
||||||
from bec_widgets.qt_utils.settings_dialog import SettingWidget
|
from bec_widgets.qt_utils.settings_dialog import SettingWidget
|
||||||
from bec_widgets.utils import UILoader
|
from bec_widgets.utils import UILoader
|
||||||
from bec_widgets.utils.widget_io import WidgetIO
|
from bec_widgets.utils.widget_io import WidgetIO
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from qtpy.QtCore import Slot
|
|
||||||
from qtpy.QtWidgets import QPushButton
|
from qtpy.QtWidgets import QPushButton
|
||||||
|
|
||||||
|
from bec_widgets.qt_utils.error_popups import SafeSlot as Slot
|
||||||
from bec_widgets.utils.bec_widget import BECWidget
|
from bec_widgets.utils.bec_widget import BECWidget
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from qtpy.QtCore import Slot
|
|
||||||
from qtpy.QtWidgets import QDialog, QTreeWidgetItem, QVBoxLayout
|
from qtpy.QtWidgets import QDialog, QTreeWidgetItem, QVBoxLayout
|
||||||
|
|
||||||
|
from bec_widgets.qt_utils.error_popups import SafeSlot as Slot
|
||||||
from bec_widgets.utils import UILoader
|
from bec_widgets.utils import UILoader
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from qtpy.QtCore import Slot
|
|
||||||
from qtpy.QtWidgets import QApplication
|
from qtpy.QtWidgets import QApplication
|
||||||
|
|
||||||
|
from bec_widgets.qt_utils.error_popups import SafeSlot as Slot
|
||||||
from bec_widgets.utils import BECConnector, ConnectionConfig
|
from bec_widgets.utils import BECConnector, ConnectionConfig
|
||||||
|
|
||||||
from .client_mocks import mocked_client
|
from .client_mocks import mocked_client
|
||||||
|
Reference in New Issue
Block a user