diff --git a/pxiii_bec/bec_widgets/widgets/client.py b/pxiii_bec/bec_widgets/widgets/client.py index 666d6db..c560848 100644 --- a/pxiii_bec/bec_widgets/widgets/client.py +++ b/pxiii_bec/bec_widgets/widgets/client.py @@ -15,6 +15,7 @@ logger = bec_logger.logger _Widgets = { "PxIIIActorConfigWidget": "PxIIIActorConfigWidget", "PxIIIAutomationPermissionWidget": "PxIIIAutomationPermissionWidget", + "PxIIICurrentSampleWidget": "PxIIICurrentSampleWidget", "PxIIISampleQueueWidget": "PxIIISampleQueueWidget", "PxIIISpreadsheetDisplay": "PxIIISpreadsheetDisplay", "PxIIITaskPanel": "PxIIITaskPanel", @@ -50,6 +51,23 @@ class PxIIIAutomationPermissionWidget(RPCBase): """ +class PxIIICurrentSampleWidget(RPCBase): + _IMPORT_MODULE = "pxiii_bec.bec_widgets.widgets.imported" + + @rpc_call + def refresh(self): + """ + Show the sample which was mounted last, as announced by the AareBec service. + """ + + @rpc_call + def show_sample(self, sample_id: "int"): + """ + Fetch the record of the sample with this database id from AareDAQ and show it. + Returns at once; the record, or why it could not be fetched, appears in the widget. + """ + + class PxIIISampleQueueWidget(RPCBase): _IMPORT_MODULE = "pxiii_bec.bec_widgets.widgets.imported" diff --git a/pxiii_bec/bec_widgets/widgets/designer_plugins.py b/pxiii_bec/bec_widgets/widgets/designer_plugins.py index 7b1e2f7..e0a25d7 100644 --- a/pxiii_bec/bec_widgets/widgets/designer_plugins.py +++ b/pxiii_bec/bec_widgets/widgets/designer_plugins.py @@ -10,6 +10,10 @@ designer_plugins = { "pxiii_bec.bec_widgets.widgets.imported", "PxIIIAutomationPermissionWidget", ), + "PxIIICurrentSampleWidget": ( + "pxiii_bec.bec_widgets.widgets.imported", + "PxIIICurrentSampleWidget", + ), "PxIIISampleQueueWidget": ("pxiii_bec.bec_widgets.widgets.imported", "PxIIISampleQueueWidget"), "PxIIISpreadsheetDisplay": ( "pxiii_bec.bec_widgets.widgets.imported", @@ -23,6 +27,7 @@ designer_plugins = { widget_icons = { "PxIIIActorConfigWidget": "format_list_bulleted", "PxIIIAutomationPermissionWidget": "key", + "PxIIICurrentSampleWidget": "science", "PxIIISampleQueueWidget": "pending_actions", "PxIIISpreadsheetDisplay": "format_list_bulleted", "PxIIITaskPanel": "play_arrow", diff --git a/pxiii_bec/bec_widgets/widgets/imported.py b/pxiii_bec/bec_widgets/widgets/imported.py index aebf76e..4a56dce 100644 --- a/pxiii_bec/bec_widgets/widgets/imported.py +++ b/pxiii_bec/bec_widgets/widgets/imported.py @@ -1,6 +1,7 @@ from mx_bec.bec_widgets.widgets.aare_bec import ( MxActorConfigWidget, MxAutomationPermissionWidget, + MxCurrentSampleWidget, MxTaskPanel, MxTaskQueueWidget, SampleQueueWidget, @@ -24,3 +25,6 @@ class PxIIISpreadsheetDisplay(SampleSpreadsheetDisplay): ... class PxIIIAutomationPermissionWidget(MxAutomationPermissionWidget): ... + + +class PxIIICurrentSampleWidget(MxCurrentSampleWidget): ... diff --git a/pxiii_bec/bec_widgets/widgets/px_iii_current_sample_widget.pyproject b/pxiii_bec/bec_widgets/widgets/px_iii_current_sample_widget.pyproject new file mode 100644 index 0000000..4cbb48d --- /dev/null +++ b/pxiii_bec/bec_widgets/widgets/px_iii_current_sample_widget.pyproject @@ -0,0 +1 @@ +{'files': ['imported.py']} \ No newline at end of file diff --git a/pxiii_bec/bec_widgets/widgets/px_iii_current_sample_widget_plugin.py b/pxiii_bec/bec_widgets/widgets/px_iii_current_sample_widget_plugin.py new file mode 100644 index 0000000..2d44706 --- /dev/null +++ b/pxiii_bec/bec_widgets/widgets/px_iii_current_sample_widget_plugin.py @@ -0,0 +1,57 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +from qtpy.QtDesigner import QDesignerCustomWidgetInterface +from qtpy.QtWidgets import QWidget + +from bec_widgets.utils.bec_designer import designer_material_icon +from pxiii_bec.bec_widgets.widgets.imported import PxIIICurrentSampleWidget + +DOM_XML = """ + + + + +""" + + +class PxIIICurrentSampleWidgetPlugin(QDesignerCustomWidgetInterface): # pragma: no cover + def __init__(self): + super().__init__() + self._form_editor = None + + def createWidget(self, parent): + if parent is None: + return QWidget() + t = PxIIICurrentSampleWidget(parent) + return t + + def domXml(self): + return DOM_XML + + def group(self): + return "" + + def icon(self): + return designer_material_icon(PxIIICurrentSampleWidget.ICON_NAME) + + def includeFile(self): + return "px_iii_current_sample_widget" + + def initialize(self, form_editor): + self._form_editor = form_editor + + def isContainer(self): + return False + + def isInitialized(self): + return self._form_editor is not None + + def name(self): + return "PxIIICurrentSampleWidget" + + def toolTip(self): + return "PxIIICurrentSampleWidget" + + def whatsThis(self): + return self.toolTip() diff --git a/pxiii_bec/bec_widgets/widgets/register_px_iii_current_sample_widget.py b/pxiii_bec/bec_widgets/widgets/register_px_iii_current_sample_widget.py new file mode 100644 index 0000000..5136907 --- /dev/null +++ b/pxiii_bec/bec_widgets/widgets/register_px_iii_current_sample_widget.py @@ -0,0 +1,15 @@ +def main(): # pragma: no cover + from qtpy import PYSIDE6 + + if not PYSIDE6: + print("PYSIDE6 is not available in the environment. Cannot patch designer.") + return + from PySide6.QtDesigner import QPyDesignerCustomWidgetCollection + + from pxiii_bec.bec_widgets.widgets.px_iii_current_sample_widget_plugin import PxIIICurrentSampleWidgetPlugin + + QPyDesignerCustomWidgetCollection.addCustomWidget(PxIIICurrentSampleWidgetPlugin()) + + +if __name__ == "__main__": # pragma: no cover + main()