mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 11:41:49 +02:00
refactor(toolbar): toolbar moved from widgets to qt_utils
This commit is contained in:
0
bec_widgets/qt_utils/__init__.py
Normal file
0
bec_widgets/qt_utils/__init__.py
Normal file
@ -3,8 +3,7 @@ from collections import defaultdict
|
|||||||
|
|
||||||
# pylint: disable=no-name-in-module
|
# pylint: disable=no-name-in-module
|
||||||
from qtpy.QtCore import QSize
|
from qtpy.QtCore import QSize
|
||||||
from qtpy.QtGui import QAction
|
from qtpy.QtWidgets import QToolBar, QWidget
|
||||||
from qtpy.QtWidgets import QHBoxLayout, QLabel, QSpinBox, QToolBar, QWidget
|
|
||||||
|
|
||||||
|
|
||||||
class ToolBarAction(ABC):
|
class ToolBarAction(ABC):
|
||||||
@ -18,34 +17,6 @@ class ToolBarAction(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class ColumnAdjustAction(ToolBarAction):
|
|
||||||
"""Toolbar spinbox to adjust number of columns in the plot layout"""
|
|
||||||
|
|
||||||
def add_to_toolbar(self, toolbar: QToolBar, target: QWidget):
|
|
||||||
"""Creates a access history button for the toolbar.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
toolbar (QToolBar): The toolbar to add the action to.
|
|
||||||
target (QWidget): The widget that the 'Access Scan History' action will be targeted.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
QAction: The 'Access Scan History' action created for the toolbar.
|
|
||||||
"""
|
|
||||||
widget = QWidget()
|
|
||||||
layout = QHBoxLayout(widget)
|
|
||||||
|
|
||||||
label = QLabel("Columns:")
|
|
||||||
spin_box = QSpinBox()
|
|
||||||
spin_box.setMinimum(1) # Set minimum value
|
|
||||||
spin_box.setMaximum(10) # Set maximum value
|
|
||||||
spin_box.setValue(target.get_column_count()) # Initial value
|
|
||||||
spin_box.valueChanged.connect(lambda value: target.set_column_count(value))
|
|
||||||
|
|
||||||
layout.addWidget(label)
|
|
||||||
layout.addWidget(spin_box)
|
|
||||||
toolbar.addWidget(widget)
|
|
||||||
|
|
||||||
|
|
||||||
class ModularToolBar(QToolBar):
|
class ModularToolBar(QToolBar):
|
||||||
"""Modular toolbar with optional automatic initialization.
|
"""Modular toolbar with optional automatic initialization.
|
||||||
Args:
|
Args:
|
@ -4,8 +4,8 @@ from qtpy.QtCore import QSize
|
|||||||
from qtpy.QtGui import QAction, QIcon
|
from qtpy.QtGui import QAction, QIcon
|
||||||
from qtpy.QtWidgets import QHBoxLayout, QLabel, QWidget
|
from qtpy.QtWidgets import QHBoxLayout, QLabel, QWidget
|
||||||
|
|
||||||
|
from bec_widgets.qt_utils.toolbar import ToolBarAction
|
||||||
from bec_widgets.widgets.device_combobox.device_combobox import DeviceComboBox
|
from bec_widgets.widgets.device_combobox.device_combobox import DeviceComboBox
|
||||||
from bec_widgets.widgets.toolbar.toolbar import ToolBarAction
|
|
||||||
|
|
||||||
|
|
||||||
class DeviceSelectionAction(ToolBarAction):
|
class DeviceSelectionAction(ToolBarAction):
|
||||||
|
@ -4,6 +4,7 @@ import sys
|
|||||||
|
|
||||||
from qtpy.QtWidgets import QVBoxLayout, QWidget
|
from qtpy.QtWidgets import QVBoxLayout, QWidget
|
||||||
|
|
||||||
|
from bec_widgets.qt_utils.toolbar import ModularToolBar
|
||||||
from bec_widgets.utils import BECConnector
|
from bec_widgets.utils import BECConnector
|
||||||
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
|
||||||
@ -14,7 +15,6 @@ from bec_widgets.widgets.motor_map.motor_map_dialog.motor_map_toolbar import (
|
|||||||
ResetHistoryAction,
|
ResetHistoryAction,
|
||||||
SettingsAction,
|
SettingsAction,
|
||||||
)
|
)
|
||||||
from bec_widgets.widgets.toolbar import ModularToolBar
|
|
||||||
|
|
||||||
|
|
||||||
class BECMotorMapWidget(BECConnector, QWidget):
|
class BECMotorMapWidget(BECConnector, QWidget):
|
||||||
|
@ -1 +0,0 @@
|
|||||||
from .toolbar import ModularToolBar
|
|
Reference in New Issue
Block a user