Bases: DevicePanel
Panel containing widgets to view sensor readings.
Create a new SensorsPanel.
Source code in frog/gui/sensors_panel.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57 | def __init__(self) -> None:
"""Create a new SensorsPanel."""
super().__init__(SENSORS_TOPIC, "Sensor readings")
self._val_lineedits: dict[str, QLineEdit] = {}
self._poll_light = LEDIcon.create_green_icon()
# As there may be many sensor readings, make the area scrollable
self._reading_layout = QFormLayout()
reading_widget = QWidget()
reading_widget.setLayout(self._reading_layout)
reading_area = QScrollArea()
reading_area.setWidget(reading_widget)
reading_area.setWidgetResizable(True)
poll_layout = QFormLayout()
poll_layout.addRow("POLL SERVER", self._poll_light)
self._poll_light.setSizePolicy(
QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed
)
layout = QVBoxLayout()
layout.addWidget(reading_area)
layout.addLayout(poll_layout)
self.setLayout(layout)
# Remove any existing sensor readings from panel
pub.subscribe(self._remove_readings_widgets, f"device.opened.{SENSORS_TOPIC}")
# Listen for readings sent by backend
pub.subscribe(self._on_readings_received, f"device.{SENSORS_TOPIC}.data")
|
Functions