mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 11:41:49 +02:00
fix: device_monitor.py BECDeviceMonitor can be promoted in the QtDesigner and then setup in the modular app
This commit is contained in:
@ -23,7 +23,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QGraphicsView" name="glw_1"/>
|
||||
<widget class="BECDeviceMonitor" name="plot_1"/>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QPushButton" name="pushButton_setting_2">
|
||||
@ -33,7 +33,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2" colspan="2">
|
||||
<widget class="QGraphicsView" name="glw_2"/>
|
||||
<widget class="BECDeviceMonitor" name="plot_2"/>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="QLabel" name="label_2">
|
||||
@ -64,7 +64,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4" colspan="2">
|
||||
<widget class="QGraphicsView" name="glw_3"/>
|
||||
<widget class="BECDeviceMonitor" name="plot_3"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@ -74,18 +74,19 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1433</width>
|
||||
<height>37</height>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuSettings">
|
||||
<property name="title">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
</widget>
|
||||
<addaction name="menuSettings"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BECDeviceMonitor</class>
|
||||
<extends>QGraphicsView</extends>
|
||||
<header location="global">bec_widgets.widgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
@ -5,6 +5,7 @@ from PyQt5.QtWidgets import QMainWindow, QApplication, QVBoxLayout
|
||||
|
||||
from bec_widgets.widgets.monitor import BECDeviceMonitor
|
||||
|
||||
# some default configs for demonstration purposes
|
||||
config_1 = {
|
||||
"plot_settings": {
|
||||
"background_color": "black",
|
||||
@ -184,29 +185,15 @@ class ModularApp(QMainWindow):
|
||||
self._init_plots()
|
||||
|
||||
def _init_plots(self):
|
||||
self.glw_1_layout = QVBoxLayout(self.glw_1) # Create a new QVBoxLayout
|
||||
self.bec_device_monitor_1 = BECDeviceMonitor(parent=self, config=config_1)
|
||||
self.glw_1_layout.addWidget(self.bec_device_monitor_1) # Add BECDeviceMonitor to the layout
|
||||
self.pushButton_setting_1.clicked.connect(
|
||||
lambda: self.bec_device_monitor_1.show_config_dialog()
|
||||
)
|
||||
"""Initialize plots and connect the buttons to the config dialogs"""
|
||||
plots = [self.plot_1, self.plot_2, self.plot_3]
|
||||
configs = [config_1, config_2, config_scan_mode]
|
||||
buttons = [self.pushButton_setting_1, self.pushButton_setting_2, self.pushButton_setting_3]
|
||||
|
||||
self.glw_2_layout = QVBoxLayout(self.glw_2) # Create a new QVBoxLayout
|
||||
self.bec_device_monitor_2 = BECDeviceMonitor(parent=self, config=config_2)
|
||||
self.glw_2_layout.addWidget(self.bec_device_monitor_2) # Add BECDeviceMonitor to the layout
|
||||
self.pushButton_setting_2.clicked.connect(
|
||||
lambda: self.bec_device_monitor_2.show_config_dialog()
|
||||
)
|
||||
|
||||
self.glw_3_layout = QVBoxLayout(self.glw_3) # Create a new QVBoxLayout
|
||||
self.bec_device_monitor_3 = BECDeviceMonitor(parent=self, config=config_scan_mode)
|
||||
self.glw_3_layout.addWidget(self.bec_device_monitor_3) # Add BECDeviceMonitor to the layout
|
||||
self.pushButton_setting_3.clicked.connect(
|
||||
lambda: self.bec_device_monitor_3.show_config_dialog()
|
||||
)
|
||||
|
||||
def show_config_dialog(self, monitor):
|
||||
monitor.show_config_dialog()
|
||||
# hook plots, configs and buttons together
|
||||
for plot, config, button in zip(plots, configs, buttons):
|
||||
plot.update_config(config)
|
||||
button.clicked.connect(plot.show_config_dialog)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Reference in New Issue
Block a user