mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 03:31:50 +02:00
feat(motor_map_widget): combobox in toolbar changes color if changed
This commit is contained in:
@ -23,6 +23,8 @@ class DeviceSelectionAction(ToolBarAction):
|
|||||||
self.label = label
|
self.label = label
|
||||||
self.device_combobox = DeviceComboBox(device_filter="Positioner")
|
self.device_combobox = DeviceComboBox(device_filter="Positioner")
|
||||||
|
|
||||||
|
self.device_combobox.currentIndexChanged.connect(lambda: self.set_combobox_style("#ffa700"))
|
||||||
|
|
||||||
def add_to_toolbar(self, toolbar, target):
|
def add_to_toolbar(self, toolbar, target):
|
||||||
widget = QWidget()
|
widget = QWidget()
|
||||||
layout = QHBoxLayout(widget)
|
layout = QHBoxLayout(widget)
|
||||||
@ -33,6 +35,9 @@ class DeviceSelectionAction(ToolBarAction):
|
|||||||
layout.addWidget(self.device_combobox)
|
layout.addWidget(self.device_combobox)
|
||||||
toolbar.addWidget(widget)
|
toolbar.addWidget(widget)
|
||||||
|
|
||||||
|
def set_combobox_style(self, color: str):
|
||||||
|
self.device_combobox.setStyleSheet(f"QComboBox {{ background-color: {color}; }}")
|
||||||
|
|
||||||
|
|
||||||
class ConnectAction(ToolBarAction):
|
class ConnectAction(ToolBarAction):
|
||||||
def add_to_toolbar(self, toolbar, target):
|
def add_to_toolbar(self, toolbar, target):
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
from qtpy.QtWidgets import QVBoxLayout, QWidget
|
from qtpy.QtWidgets import QVBoxLayout, QWidget
|
||||||
|
|
||||||
from bec_widgets.utils import BECConnector
|
from bec_widgets.utils import BECConnector, UILoader
|
||||||
from bec_widgets.widgets.figure import BECFigure
|
from bec_widgets.widgets.figure import BECFigure
|
||||||
from bec_widgets.widgets.figure.plots.motor_map.motor_map import MotorMapConfig
|
from bec_widgets.widgets.figure.plots.motor_map.motor_map import MotorMapConfig
|
||||||
from bec_widgets.widgets.motor_map.motor_map_toolbar import (
|
from bec_widgets.widgets.motor_map.motor_map_toolbar import (
|
||||||
@ -69,9 +71,13 @@ class BECMotorMapWidget(BECConnector, QWidget):
|
|||||||
self.toolbar.widgets["connect"].action.triggered.connect(self._action_motors)
|
self.toolbar.widgets["connect"].action.triggered.connect(self._action_motors)
|
||||||
|
|
||||||
def _action_motors(self):
|
def _action_motors(self):
|
||||||
motor_x = self.toolbar.widgets["motor_x"].device_combobox.currentText()
|
toolbar_x = self.toolbar.widgets["motor_x"].device_combobox
|
||||||
motor_y = self.toolbar.widgets["motor_y"].device_combobox.currentText()
|
toolbar_y = self.toolbar.widgets["motor_y"].device_combobox
|
||||||
|
motor_x = toolbar_x.currentText()
|
||||||
|
motor_y = toolbar_y.currentText()
|
||||||
self.change_motors(motor_x, motor_y, None, None, True)
|
self.change_motors(motor_x, motor_y, None, None, True)
|
||||||
|
toolbar_x.setStyleSheet("QComboBox {{ background-color: " "; }}")
|
||||||
|
toolbar_y.setStyleSheet("QComboBox {{ background-color: " "; }}")
|
||||||
|
|
||||||
###################################
|
###################################
|
||||||
# User Access Methods from MotorMap
|
# User Access Methods from MotorMap
|
||||||
@ -170,7 +176,7 @@ class BECMotorMapWidget(BECConnector, QWidget):
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PySide6.QtWidgets import QApplication
|
from PySide6.QtWidgets import QApplication, QDialog
|
||||||
|
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
widget = BECMotorMapWidget()
|
widget = BECMotorMapWidget()
|
||||||
|
Reference in New Issue
Block a user