Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ numpydoc
ophyd
pcdsutils
platformdirs
PyQt5
pydm>=1.19.1
pyqtgraph
pyyaml
Expand Down
23 changes: 13 additions & 10 deletions typhos/alarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ class TyphosAlarm(TyphosObject, PyDMDrawing, _KindLevel, _AlarmLevel):
We will consider a subset of the signals that is of KindLevel and above and
summarize state based on the "worst" alarm we see as defined by AlarmLevel.
"""
QtCore.Q_ENUMS(_KindLevel)
QtCore.Q_ENUMS(_AlarmLevel)
QtCore.Q_ENUMS(KindLevel)
QtCore.Q_ENUMS(AlarmLevel)

KindLevel = KindLevel
AlarmLevel = AlarmLevel
Expand All @@ -119,11 +119,14 @@ class TyphosAlarm(TyphosObject, PyDMDrawing, _KindLevel, _AlarmLevel):
def __init__(self, *args, **kwargs):
self._kind_level = KindLevel.HINTED
super().__init__(*args, **kwargs)
QtCore.QTimer.singleShot(0, self._finish_init)
self.reset_alarm_state()

def _finish_init(self):
# Default drawing properties, can override if needed
self.penWidth = 2
self.penColor = QtGui.QColor('black')
self.penStyle = Qt.SolidLine
self.reset_alarm_state()
self.alarm_changed.connect(self.set_alarm_color)

@QtCore.Property(_KindLevel)
Expand Down Expand Up @@ -210,13 +213,13 @@ def reset_alarm_state(self):
self.signal_info = {}
self.device_info = defaultdict(list)
self.alarm_summary = AlarmLevel.DISCONNECTED
self.set_alarm_color(AlarmLevel.DISCONNECTED)
QtCore.QTimer.singleShot(0, partial(self.set_alarm_color, AlarmLevel.DISCONNECTED))

def channels(self):
"""
Let pydm know about our pydm channels.
"""
ch = list(self._channels)
ch = list(getattr(self, '_channels', []))
for info in self.signal_info.values():
ch.append(info.channel)
return ch
Expand Down Expand Up @@ -395,27 +398,27 @@ def show_alarm_tooltip(self, event):
# Each of these must be included for these to work in designer

class TyphosAlarmCircle(TyphosAlarm, PyDMDrawingCircle):
QtCore.Q_ENUMS(_KindLevel)
QtCore.Q_ENUMS(KindLevel)
kindLevel = TyphosAlarm.kindLevel


class TyphosAlarmRectangle(TyphosAlarm, PyDMDrawingRectangle):
QtCore.Q_ENUMS(_KindLevel)
QtCore.Q_ENUMS(KindLevel)
kindLevel = TyphosAlarm.kindLevel


class TyphosAlarmTriangle(TyphosAlarm, PyDMDrawingTriangle):
QtCore.Q_ENUMS(_KindLevel)
QtCore.Q_ENUMS(KindLevel)
kindLevel = TyphosAlarm.kindLevel


class TyphosAlarmEllipse(TyphosAlarm, PyDMDrawingEllipse):
QtCore.Q_ENUMS(_KindLevel)
QtCore.Q_ENUMS(KindLevel)
kindLevel = TyphosAlarm.kindLevel


class TyphosAlarmPolygon(TyphosAlarm, PyDMDrawingPolygon):
QtCore.Q_ENUMS(_KindLevel)
QtCore.Q_ENUMS(KindLevel)
kindLevel = TyphosAlarm.kindLevel
numberOfPoints = PyDMDrawingPolygon.numberOfPoints

Expand Down
20 changes: 10 additions & 10 deletions typhos/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class TyphosDisplayConfigButton(TyphosToolButton):

def __init__(self, icon=None, *, parent=None):
super().__init__(icon=icon, parent=parent)
self.setPopupMode(self.InstantPopup)
self.setPopupMode(self.ToolButtonPopupMode.InstantPopup)
self.setArrowType(Qt.NoArrow)
self.templates = None
self.device_display = None
Expand Down Expand Up @@ -838,8 +838,8 @@ def __init__(self, title='${name}', *, show_switcher=True,
self.switcher = TyphosDisplaySwitcher()

self.underline = QtWidgets.QFrame()
self.underline.setFrameShape(self.underline.HLine)
self.underline.setFrameShadow(self.underline.Plain)
self.underline.setFrameShape(self.underline.Shape.HLine)
self.underline.setFrameShadow(self.underline.Shadow.Plain)
self.underline.setLineWidth(10)

self.notes_edit = TyphosNotesEdit()
Expand Down Expand Up @@ -877,7 +877,7 @@ def __init__(self, title='${name}', *, show_switcher=True,

self.grid_layout.addWidget(self.help, 2, 0, 1, 2)

self.grid_layout.setSizeConstraint(self.grid_layout.SetMinimumSize)
self.grid_layout.setSizeConstraint(self.grid_layout.SizeConstraint.SetMinimumSize)
self.setLayout(self.grid_layout)

# Set the property:
Expand Down Expand Up @@ -945,7 +945,7 @@ def toggle():
self.label.toggle_requested.connect(toggle)

# Make designable properties from the title label available here as well
label_alignment = forward_property('label', QtWidgets.QLabel, 'alignment')
# label_alignment = forward_property('label', QtWidgets.QLabel, 'alignment')
label_font = forward_property('label', QtWidgets.QLabel, 'font')
label_indent = forward_property('label', QtWidgets.QLabel, 'indent')
label_margin = forward_property('label', QtWidgets.QLabel, 'margin')
Expand All @@ -955,13 +955,13 @@ def toggle():
label_text = forward_property('label', QtWidgets.QLabel, 'text')
label_textFormat = forward_property('label', QtWidgets.QLabel,
'textFormat')
label_textInteractionFlags = forward_property('label', QtWidgets.QLabel,
'textInteractionFlags')
# label_textInteractionFlags = forward_property('label', QtWidgets.QLabel,
# 'textInteractionFlags')
label_wordWrap = forward_property('label', QtWidgets.QLabel, 'wordWrap')

# Make designable properties from the grid_layout
layout_margin = forward_property('grid_layout', QtWidgets.QHBoxLayout,
'margin')
# layout_margin = forward_property('grid_layout', QtWidgets.QHBoxLayout,
# 'margin')
layout_spacing = forward_property('grid_layout', QtWidgets.QHBoxLayout,
'spacing')

Expand Down Expand Up @@ -1019,7 +1019,7 @@ class TyphosDeviceDisplay(utils.TyphosBase, widgets.TyphosDesignerMixin,
"""

# Template types and defaults
Q_ENUMS(_DisplayTypes)
Q_ENUMS(DisplayTypes)
TemplateEnum = DisplayTypes # For convenience
template_changed = QtCore.Signal(object)
templates_loaded = QtCore.Signal(object)
Expand Down
21 changes: 14 additions & 7 deletions typhos/notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,10 @@ class TyphosNotesEdit(
}

def __init__(self, *args, refresh_time: float = 5.0, **kwargs):
super().__init__(*args, **kwargs)
self.editingFinished.connect(self.save_note)
self.setPlaceholderText('no notes...')
self.edit_filter = utils.FrameOnEditFilter(parent=self)
self.setFrame(False)
self.installEventFilter(self.edit_filter)
self._last_updated: Optional[float] = None
QtWidgets.QLineEdit.__init__(self, *args, **kwargs) # This will call both parent __init__ methods
utils.TyphosBase.__init__(self)
self._refresh_time: float = refresh_time

# to be initialized later
self.device_name: Optional[str] = None
self.notes_source: Optional[NotesSource] = None
Expand All @@ -195,6 +191,17 @@ def __init__(self, *args, refresh_time: float = 5.0, **kwargs):
QtWidgets.QSizePolicy.MinimumExpanding,
QtWidgets.QSizePolicy.Preferred
)
self._last_updated: Optional[float] = None

QtCore.QTimer.singleShot(0, self._finish_init)

def _finish_init(self):
self.editingFinished.connect(self.save_note)
self.setPlaceholderText('no notes...')
self.edit_filter = utils.FrameOnEditFilter(parent=self)
self.setFrame(False)
self.installEventFilter(self.edit_filter)


def update_tooltip(self) -> None:
if self.data['note'] and self.notes_source is not None:
Expand Down
13 changes: 6 additions & 7 deletions typhos/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import functools
import logging
from enum import Enum
from functools import partial
from typing import Dict, List, Optional

Expand All @@ -31,7 +32,7 @@
logger = logging.getLogger(__name__)


class SignalOrder:
class SignalOrder(Enum):
"""
Options for sorting signals.

Expand Down Expand Up @@ -667,7 +668,7 @@ def add_device(self, device):
self._maybe_add_signal(device, walk.item.attr, walk.dotted_name,
walk.item)

self.setSizeConstraint(self.SetMinimumSize)
self.setSizeConstraint(self.SizeConstraint.SetMinimumSize)

def _maybe_add_signal(self, device, attr, dotted_name, component):
"""
Expand Down Expand Up @@ -714,10 +715,8 @@ def _maybe_add_signal(self, device, attr, dotted_name, component):
logger.warning('Failed to get signal %r from device %s: %s',
dotted_name, device.name, ex, exc_info=True)
return
# Workaround until Ophyd.Component.long_name PR comes through
long_name = self._get_long_name(device, attr, dotted_name)
return self.add_signal(signal=signal, name=attr, long_name=long_name,
tooltip=component.doc)

return self.add_signal(signal, name=component.kwargs.get('name', attr), tooltip=component.doc)

return self._add_component(device, attr, dotted_name, component)

Expand All @@ -729,7 +728,7 @@ def clear(self):
self.signal_name_to_info.clear()


class TyphosSignalPanel(TyphosBase, TyphosDesignerMixin, SignalOrder):
class TyphosSignalPanel(TyphosBase, TyphosDesignerMixin):
"""
Panel of Signals for a given device, using :class:`SignalPanel`.

Expand Down
17 changes: 13 additions & 4 deletions typhos/positioner.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class TyphosPositionerWidget(
``hinted`` signals.
============== ===========================================================
"""
QtCore.Q_ENUMS(_KindLevel)
QtCore.Q_ENUMS(KindLevel)
KindLevel = KindLevel

ui: _TyphosPositionerUI
Expand Down Expand Up @@ -179,6 +179,12 @@ def __init__(self, parent=None):
super().__init__(parent=parent)

self.ui = typing.cast(_TyphosPositionerUI, uic.loadUi(self.ui_template, self))

QtCore.QTimer.singleShot(0, self._finish_init)

def _finish_init(self):


self.ui.tweak_positive.clicked.connect(self.positive_tweak)
self.ui.tweak_negative.clicked.connect(self.negative_tweak)
self.ui.stop_button.clicked.connect(self.stop)
Expand All @@ -198,7 +204,7 @@ def _clear_status_thread(self):
return

logger.debug("Clearing current active status")
self._status_thread.disconnect()
self._status_thread.disconnect(self)
self._status_thread = None

def _start_status_thread(
Expand Down Expand Up @@ -732,7 +738,7 @@ def show_expert_button(self):
inside of an unrelated screen.
This will default to False.
"""
return self._show_expert_button
return getattr(self, '_show_expert_button', False)

@show_expert_button.setter
def show_expert_button(self, show):
Expand Down Expand Up @@ -939,6 +945,9 @@ def __init__(self, *args, **kwargs):
self._alarm_level = AlarmLevel.DISCONNECTED

super().__init__(*args, **kwargs)

def _finish_init(self):
super()._finish_init()
dynamic_font.patch_widget(self.ui.low_limit, pad_percent=0.01, max_size=12, min_size=4)
dynamic_font.patch_widget(self.ui.high_limit, pad_percent=0.01, max_size=12, min_size=4)
dynamic_font.patch_widget(self.ui.device_name_label, pad_percent=0.01, min_size=4)
Expand Down Expand Up @@ -1024,7 +1033,7 @@ def _create_signal_panel(self) -> Optional[TyphosSignalPanel]:
if self.device is None:
return None

return RowDetails(row=self, parent=self, flags=QtCore.Qt.Window)
return RowDetails(row=self, parent=self, f=QtCore.Qt.Window)

def _expand_layout(self) -> None:
"""Toggle the expansion of the signal panel."""
Expand Down
5 changes: 4 additions & 1 deletion typhos/related_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def happi_check():
return happi_loaded


class TyphosRelatedSuiteButton(TyphosObject, QtWidgets.QPushButton):
class TyphosRelatedSuiteButton(QtWidgets.QPushButton, TyphosObject):
"""
Button to open a typhos suite with happi-loaded devices.
"""
Expand All @@ -46,6 +46,9 @@ def __init__(self, *args, **kwargs):
self._happi_cfg = ''
self._preload = False
self._suite = None
QtCore.QTimer.singleShot(0, self._finish_init)

def _finish_init(self):
self.clicked.connect(self.show_suite)

@QtCore.Property('QStringList')
Expand Down
4 changes: 3 additions & 1 deletion typhos/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,9 @@ def _get_sidebar(self, widget):
items = {}
for group in self.top_level_groups.values():
for item in flatten_tree(group):
items[item.value()] = item
value = item.opts.get('value', None)
if value:
items[value] = item
return items.get(widget)

def _show_sidebar(self, widget, dock):
Expand Down
6 changes: 3 additions & 3 deletions typhos/ui/core/detailed_screen.ui
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
<item>
<spacer name="normal_spacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -279,7 +279,7 @@
<item>
<spacer name="config_spacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand All @@ -300,7 +300,7 @@
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down
2 changes: 1 addition & 1 deletion typhos/ui/core/embedded_screen.ui
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down
6 changes: 3 additions & 3 deletions typhos/ui/core/engineering_screen.ui
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<item>
<spacer name="read_spacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -158,7 +158,7 @@
<item>
<spacer name="config_spacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand All @@ -175,7 +175,7 @@
<item>
<spacer name="frame_spacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down
Loading