-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1044 from nstelter-slac/multistate_widget_base
Basic version of multi-state LED indicator widget
- Loading branch information
Showing
7 changed files
with
666 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
####################### | ||
PyDMMultiStateIndicator | ||
####################### | ||
|
||
.. autoclass:: pydm.widgets.byte.PyDMMultiStateIndicator | ||
:members: | ||
:show-inheritance: | ||
|
||
|
||
.. note:: | ||
See `QWidget Documentation <https://doc.qt.io/qtforpython-5/PySide2/QtWidgets/QWidget.html>`_ for all inherited properties and methods. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>Form</class> | ||
<widget class="QWidget" name="Form"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>325</width> | ||
<height>264</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Form</string> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<item> | ||
<layout class="QHBoxLayout" name="horizontalLayout"> | ||
<item> | ||
<widget class="PyDMMultiStateIndicator" name="PyDMMultiStateIndicator"> | ||
<property name="toolTip"> | ||
<string/> | ||
</property> | ||
<property name="channel" stdset="0"> | ||
<string>ca://MTEST:Float</string> | ||
</property> | ||
<property name="renderAsRectangle" stdset="0"> | ||
<bool>false</bool> | ||
</property> | ||
<property name="state0Color" stdset="0"> | ||
<color> | ||
<red>0</red> | ||
<green>0</green> | ||
<blue>0</blue> | ||
</color> | ||
</property> | ||
<property name="state1Color" stdset="0"> | ||
<color> | ||
<red>170</red> | ||
<green>0</green> | ||
<blue>0</blue> | ||
</color> | ||
</property> | ||
<property name="state2Color" stdset="0"> | ||
<color> | ||
<red>0</red> | ||
<green>85</green> | ||
<blue>0</blue> | ||
</color> | ||
</property> | ||
<property name="state3Color" stdset="0"> | ||
<color> | ||
<red>170</red> | ||
<green>85</green> | ||
<blue>0</blue> | ||
</color> | ||
</property> | ||
<property name="state4Color" stdset="0"> | ||
<color> | ||
<red>0</red> | ||
<green>170</green> | ||
<blue>0</blue> | ||
</color> | ||
</property> | ||
<property name="state5Color" stdset="0"> | ||
<color> | ||
<red>170</red> | ||
<green>170</green> | ||
<blue>0</blue> | ||
</color> | ||
</property> | ||
<property name="state6Color" stdset="0"> | ||
<color> | ||
<red>0</red> | ||
<green>255</green> | ||
<blue>0</blue> | ||
</color> | ||
</property> | ||
<property name="state7Color" stdset="0"> | ||
<color> | ||
<red>170</red> | ||
<green>255</green> | ||
<blue>0</blue> | ||
</color> | ||
</property> | ||
<property name="state8Color" stdset="0"> | ||
<color> | ||
<red>0</red> | ||
<green>0</green> | ||
<blue>127</blue> | ||
</color> | ||
</property> | ||
<property name="state9Color" stdset="0"> | ||
<color> | ||
<red>170</red> | ||
<green>0</green> | ||
<blue>127</blue> | ||
</color> | ||
</property> | ||
<property name="state10Color" stdset="0"> | ||
<color> | ||
<red>0</red> | ||
<green>85</green> | ||
<blue>127</blue> | ||
</color> | ||
</property> | ||
<property name="state11Color" stdset="0"> | ||
<color> | ||
<red>170</red> | ||
<green>85</green> | ||
<blue>127</blue> | ||
</color> | ||
</property> | ||
<property name="state12Color" stdset="0"> | ||
<color> | ||
<red>0</red> | ||
<green>170</green> | ||
<blue>127</blue> | ||
</color> | ||
</property> | ||
<property name="state13Color" stdset="0"> | ||
<color> | ||
<red>170</red> | ||
<green>170</green> | ||
<blue>127</blue> | ||
</color> | ||
</property> | ||
<property name="state14Color" stdset="0"> | ||
<color> | ||
<red>0</red> | ||
<green>255</green> | ||
<blue>127</blue> | ||
</color> | ||
</property> | ||
<property name="state15Color" stdset="0"> | ||
<color> | ||
<red>170</red> | ||
<green>255</green> | ||
<blue>127</blue> | ||
</color> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
</layout> | ||
</widget> | ||
<customwidgets> | ||
<customwidget> | ||
<class>PyDMMultiStateIndicator</class> | ||
<extends>QWidget</extends> | ||
<header>pydm.widgets.byte</header> | ||
</customwidget> | ||
</customwidgets> | ||
<resources/> | ||
<connections/> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import pytest | ||
|
||
from qtpy.QtGui import QColor | ||
from qtpy.QtCore import Qt | ||
from ...widgets.byte import PyDMMultiStateIndicator | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"value, expectedColor", | ||
[ | ||
(0, QColor(Qt.black)), | ||
(4, QColor(Qt.red)), | ||
(7, QColor(Qt.darkGreen)), | ||
(15, QColor(Qt.yellow)), | ||
], | ||
) | ||
def test_state_change(qtbot, signals, value, expectedColor): | ||
""" | ||
Test the widget's handling of the value changed event. | ||
Expectations: | ||
1. Widget state is update to reflect incoming signal value | ||
2. Widgets color after state-update is the correct color set for the new state | ||
Parameters | ||
---------- | ||
qtbot : fixture | ||
pytest-qt window for widget testing | ||
signals : fixture | ||
The signals fixture, which provides access signals to be bound to the appropriate slots | ||
expected : int | ||
Expected resulting color after state-update | ||
""" | ||
pydm_multistate = PyDMMultiStateIndicator() | ||
qtbot.addWidget(pydm_multistate) | ||
pydm_multistate.show() | ||
|
||
pydm_multistate.state4Color = QColor(Qt.red) | ||
pydm_multistate.state7Color = QColor(Qt.darkGreen) | ||
pydm_multistate.state15Color = QColor(Qt.yellow) | ||
|
||
pydm_multistate._connected = True | ||
|
||
signals.new_value_signal[type(value)].connect(pydm_multistate.channelValueChanged) | ||
signals.new_value_signal[type(value)].emit(value) | ||
|
||
assert pydm_multistate._curr_state == value | ||
assert pydm_multistate._curr_color == expectedColor |
Oops, something went wrong.