mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 11:41:49 +02:00
feat: modular_app.py, device_monitor.py, config_dialog.py linked together, plot configuration can be done through GUI
This commit is contained in:
@ -15,16 +15,40 @@
|
|||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QWidget" name="centralwidget">
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="2" column="1">
|
<item row="1" column="2">
|
||||||
<widget class="QGraphicsView" name="glw_2"/>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Plot Config 2</string>
|
<string>Plot Config 2</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="0" colspan="2">
|
||||||
|
<widget class="QGraphicsView" name="glw_1"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="3">
|
||||||
|
<widget class="QPushButton" name="pushButton_setting_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Setting Plot 2</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="2" colspan="2">
|
||||||
|
<widget class="QGraphicsView" name="glw_2"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="4">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Plot Scan Types = True</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QPushButton" name="pushButton_setting_1">
|
||||||
|
<property name="text">
|
||||||
|
<string>Setting Plot 1</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -32,19 +56,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="1" column="5">
|
||||||
<widget class="QGraphicsView" name="glw_1"/>
|
<widget class="QPushButton" name="pushButton_setting_3">
|
||||||
</item>
|
|
||||||
<item row="2" column="2">
|
|
||||||
<widget class="QGraphicsView" name="glw_3"/>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="2">
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Plot Scan Types = True</string>
|
<string>Setting Plot 3</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="4" colspan="2">
|
||||||
|
<widget class="QGraphicsView" name="glw_3"/>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenuBar" name="menubar">
|
<widget class="QMenuBar" name="menubar">
|
||||||
@ -53,7 +74,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1433</width>
|
<width>1433</width>
|
||||||
<height>24</height>
|
<height>37</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuSettings">
|
<widget class="QMenu" name="menuSettings">
|
||||||
|
@ -3,7 +3,7 @@ import os
|
|||||||
from PyQt5 import uic
|
from PyQt5 import uic
|
||||||
from PyQt5.QtWidgets import QMainWindow, QApplication, QVBoxLayout
|
from PyQt5.QtWidgets import QMainWindow, QApplication, QVBoxLayout
|
||||||
|
|
||||||
from bec_widgets.widgets.monitor.device_monitor import BECDeviceMonitor
|
from bec_widgets.widgets.monitor import BECDeviceMonitor, ConfigDialog
|
||||||
|
|
||||||
config_1 = {
|
config_1 = {
|
||||||
"plot_settings": {
|
"plot_settings": {
|
||||||
@ -171,6 +171,18 @@ class ModularApp(QMainWindow):
|
|||||||
|
|
||||||
self._init_plots()
|
self._init_plots()
|
||||||
|
|
||||||
|
# Config Dialog
|
||||||
|
self.config_dialog = ConfigDialog()
|
||||||
|
self.pushButton_setting_1.clicked.connect(
|
||||||
|
lambda: self.show_config_dialog(config_1, self.bec_device_monitor_1)
|
||||||
|
)
|
||||||
|
self.pushButton_setting_2.clicked.connect(
|
||||||
|
lambda: self.show_config_dialog(config_2, self.bec_device_monitor_2)
|
||||||
|
)
|
||||||
|
self.pushButton_setting_3.clicked.connect(
|
||||||
|
lambda: self.show_config_dialog(config_scan_mode, self.bec_device_monitor_3)
|
||||||
|
)
|
||||||
|
|
||||||
def _init_plots(self):
|
def _init_plots(self):
|
||||||
self.glw_1_layout = QVBoxLayout(self.glw_1) # Create a new QVBoxLayout
|
self.glw_1_layout = QVBoxLayout(self.glw_1) # Create a new QVBoxLayout
|
||||||
self.bec_device_monitor_1 = BECDeviceMonitor(parent=self, config=config_1)
|
self.bec_device_monitor_1 = BECDeviceMonitor(parent=self, config=config_1)
|
||||||
@ -184,6 +196,13 @@ class ModularApp(QMainWindow):
|
|||||||
self.bec_device_monitor_3 = BECDeviceMonitor(parent=self, config=config_scan_mode)
|
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.glw_3_layout.addWidget(self.bec_device_monitor_3) # Add BECDeviceMonitor to the layout
|
||||||
|
|
||||||
|
def show_config_dialog(self, config, monitor):
|
||||||
|
# self.config_dialog.load_config(config) # Load the configuration into the dialog
|
||||||
|
self.config_dialog.config_updated.connect(
|
||||||
|
monitor.update_config
|
||||||
|
) # Connect the signal to the monitor's slot
|
||||||
|
self.config_dialog.show() # Show the dialog
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
from bec_widgets.bec_dispatcher import bec_dispatcher
|
from bec_widgets.bec_dispatcher import bec_dispatcher
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
from .device_monitor import BECDeviceMonitor
|
||||||
|
from .config_dialog import ConfigDialog
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
from PyQt5 import uic
|
from PyQt5 import uic
|
||||||
|
from PyQt5.QtCore import pyqtSignal
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QApplication,
|
QApplication,
|
||||||
QWidget,
|
QWidget,
|
||||||
@ -11,11 +14,15 @@ from PyQt5.QtWidgets import (
|
|||||||
QTableWidgetItem,
|
QTableWidgetItem,
|
||||||
)
|
)
|
||||||
|
|
||||||
Ui_Form, BaseClass = uic.loadUiType("config_dialog.ui")
|
|
||||||
Tab_Ui_Form, Tab_BaseClass = uic.loadUiType("tab_template.ui")
|
current_path = os.path.dirname(__file__)
|
||||||
|
Ui_Form, BaseClass = uic.loadUiType(os.path.join(current_path, "config_dialog.ui"))
|
||||||
|
Tab_Ui_Form, Tab_BaseClass = uic.loadUiType(os.path.join(current_path, "tab_template.ui"))
|
||||||
|
|
||||||
|
|
||||||
class MainApp(QWidget, Ui_Form):
|
class ConfigDialog(QWidget, Ui_Form):
|
||||||
|
config_updated = pyqtSignal(dict)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
@ -66,10 +73,10 @@ class MainApp(QWidget, Ui_Form):
|
|||||||
def get_configuration(self):
|
def get_configuration(self):
|
||||||
config = {
|
config = {
|
||||||
"plot_settings": {
|
"plot_settings": {
|
||||||
"background_color": "black",
|
"background_color": self.comboBox_appearance.currentText(),
|
||||||
"num_columns": self.spinBox.value(),
|
"num_columns": self.spinBox.value(),
|
||||||
"colormap": self.comboBox_2.currentText(),
|
"colormap": self.comboBox_colormap.currentText(),
|
||||||
"scan_types": self.comboBox.currentText() == "Enabled",
|
"scan_types": self.comboBox_scanTypes.currentText() == "Enabled",
|
||||||
},
|
},
|
||||||
"plot_data": [],
|
"plot_data": [],
|
||||||
}
|
}
|
||||||
@ -105,6 +112,7 @@ class MainApp(QWidget, Ui_Form):
|
|||||||
config["plot_data"].append(plot_config)
|
config["plot_data"].append(plot_config)
|
||||||
|
|
||||||
print(config)
|
print(config)
|
||||||
|
self.config_updated.emit(config)
|
||||||
return config
|
return config
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -114,6 +122,6 @@ class MainApp(QWidget, Ui_Form):
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app = QApplication([])
|
app = QApplication([])
|
||||||
main_app = MainApp()
|
main_app = ConfigDialog()
|
||||||
main_app.show()
|
main_app.show()
|
||||||
app.exec_()
|
app.exec_()
|
||||||
|
@ -132,14 +132,14 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton">
|
<widget class="QPushButton" name="pushButton_import">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Import</string>
|
<string>Import</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton_2">
|
<widget class="QPushButton" name="pushButton_export">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Export</string>
|
<string>Export</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -228,6 +228,11 @@ class BECDeviceMonitor(pg.GraphicsLayoutWidget):
|
|||||||
|
|
||||||
curve.setData(data_x, data_y)
|
curve.setData(data_x, data_y)
|
||||||
|
|
||||||
|
@pyqtSlot(dict)
|
||||||
|
def update_config(self, config):
|
||||||
|
self.config = config
|
||||||
|
self._init_config()
|
||||||
|
|
||||||
@pyqtSlot(dict, dict)
|
@pyqtSlot(dict, dict)
|
||||||
def on_scan_segment(self, msg, metadata):
|
def on_scan_segment(self, msg, metadata):
|
||||||
"""
|
"""
|
||||||
|
Reference in New Issue
Block a user