From 7685170c01631a1ea513519d355e17940283d52f Mon Sep 17 00:00:00 2001 From: tangkong Date: Wed, 13 Sep 2023 11:15:24 -0700 Subject: [PATCH 1/2] MNT: add TyphosDisplaySwitcher to positioner_row.ui --- typhos/ui/widgets/positioner_row.ui | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/typhos/ui/widgets/positioner_row.ui b/typhos/ui/widgets/positioner_row.ui index 807e1ca3..3b8fbaa6 100644 --- a/typhos/ui/widgets/positioner_row.ui +++ b/typhos/ui/widgets/positioner_row.ui @@ -115,6 +115,19 @@ + + + + + 0 + 0 + + + + + + + @@ -1258,15 +1271,20 @@ Screen
typhos.alarm
- TyphosNotesEdit - QLineEdit -
typhos.notes
+ TyphosDisplaySwitcher + QFrame +
typhos.display
TyphosRelatedSuiteButton QPushButton
typhos.related_display
+ + TyphosNotesEdit + QLineEdit +
typhos.notes
+
From 30fd85944c68345c93dbd0efd9cf4c910ffdce88 Mon Sep 17 00:00:00 2001 From: tangkong Date: Thu, 14 Sep 2023 09:58:06 -0700 Subject: [PATCH 2/2] MNT: add tooltip to switcher help button --- typhos/positioner.py | 31 +++++++++++++++++++++++++++++ typhos/ui/widgets/positioner_row.ui | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/typhos/positioner.py b/typhos/positioner.py index c218a4af..78ec85c5 100644 --- a/typhos/positioner.py +++ b/typhos/positioner.py @@ -1,5 +1,6 @@ from __future__ import annotations +import inspect import logging import os.path import threading @@ -10,6 +11,8 @@ from pydm.widgets.channel import PyDMChannel from qtpy import QtCore, QtWidgets, uic +from typhos.display import TyphosDisplaySwitcher + from . import dynamic_font, utils, widgets from .alarm import AlarmLevel, KindLevel, _KindLevel from .panel import SignalOrder, TyphosSignalPanel @@ -828,6 +831,7 @@ class _TyphosPositionerRowUI(_TyphosPositionerUI): status_container_widget: QtWidgets.QFrame extended_signal_panel: Optional[TyphosSignalPanel] error_prefix: QtWidgets.QLabel + switcher: TyphosDisplaySwitcher class TyphosPositionerRowWidget(TyphosPositionerWidget): @@ -964,6 +968,33 @@ def add_device(self, device: ophyd.Device) -> None: self.ui.device_name_label.setText(device.name) self.ui.notes_edit.add_device(device) + self.ui.switcher.help_toggle_button.setToolTip(self._get_tooltip()) + self.ui.switcher.help_toggle_button.setEnabled(False) + + def _get_tooltip(self): + """Update the tooltip based on device information.""" + # Lifted from TyphosHelpFrame + tooltip = [] + # BUG: I'm seeing two devices in `self.devices` for + # $ typhos --fake-device 'ophyd.EpicsMotor[{"prefix":"b"}]' + for device in sorted( + set(self.devices), + key=lambda dev: self.devices.index(dev) + ): + heading = device.name or type(device).__name__ + tooltip.extend([ + heading, + "-" * len(heading), + "" + ]) + + tooltip.append( + inspect.getdoc(device) or + inspect.getdoc(type(device)) or + "No docstring" + ) + tooltip.append("") + return "\n".join(tooltip) @utils.linked_attribute('error_message_attribute', 'ui.error_label', True) def _link_error_message(self, signal, widget): diff --git a/typhos/ui/widgets/positioner_row.ui b/typhos/ui/widgets/positioner_row.ui index 3b8fbaa6..85ce5e47 100644 --- a/typhos/ui/widgets/positioner_row.ui +++ b/typhos/ui/widgets/positioner_row.ui @@ -116,7 +116,7 @@
- + 0