mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 03:31:50 +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
|
||||
from qtpy.QtCore import QSize
|
||||
from qtpy.QtGui import QAction
|
||||
from qtpy.QtWidgets import QHBoxLayout, QLabel, QSpinBox, QToolBar, QWidget
|
||||
from qtpy.QtWidgets import QToolBar, QWidget
|
||||
|
||||
|
||||
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):
|
||||
"""Modular toolbar with optional automatic initialization.
|
||||
Args:
|
@ -4,8 +4,8 @@ from qtpy.QtCore import QSize
|
||||
from qtpy.QtGui import QAction, QIcon
|
||||
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.toolbar.toolbar import ToolBarAction
|
||||
|
||||
|
||||
class DeviceSelectionAction(ToolBarAction):
|
||||
|
@ -4,6 +4,7 @@ import sys
|
||||
|
||||
from qtpy.QtWidgets import QVBoxLayout, QWidget
|
||||
|
||||
from bec_widgets.qt_utils.toolbar import ModularToolBar
|
||||
from bec_widgets.utils import BECConnector
|
||||
from bec_widgets.widgets.figure import BECFigure
|
||||
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,
|
||||
SettingsAction,
|
||||
)
|
||||
from bec_widgets.widgets.toolbar import ModularToolBar
|
||||
|
||||
|
||||
class BECMotorMapWidget(BECConnector, QWidget):
|
||||
|
@ -1 +0,0 @@
|
||||
from .toolbar import ModularToolBar
|
Reference in New Issue
Block a user