mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 11:41:49 +02:00
fix(waveform): fixed icon appearance
This commit is contained in:
@ -182,20 +182,13 @@ class ModularToolBar(QToolBar):
|
|||||||
parent (QWidget, optional): The parent widget of the toolbar. Defaults to None.
|
parent (QWidget, optional): The parent widget of the toolbar. Defaults to None.
|
||||||
actions (list[ToolBarAction], optional): A list of action creators to populate the toolbar. Defaults to None.
|
actions (list[ToolBarAction], optional): A list of action creators to populate the toolbar. Defaults to None.
|
||||||
target_widget (QWidget, optional): The widget that the actions will target. Defaults to None.
|
target_widget (QWidget, optional): The widget that the actions will target. Defaults to None.
|
||||||
color (str, optional): The background color of the toolbar. Defaults to "black".
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(self, parent=None, actions: dict | None = None, target_widget=None):
|
||||||
self,
|
|
||||||
parent=None,
|
|
||||||
actions: dict | None = None,
|
|
||||||
target_widget=None,
|
|
||||||
color: str = "rgba(255, 255, 255, 0)",
|
|
||||||
):
|
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
|
||||||
self.widgets = defaultdict(dict)
|
self.widgets = defaultdict(dict)
|
||||||
self.set_background_color(color)
|
self.set_background_color()
|
||||||
|
|
||||||
if actions is not None and target_widget is not None:
|
if actions is not None and target_widget is not None:
|
||||||
self.populate_toolbar(actions, target_widget)
|
self.populate_toolbar(actions, target_widget)
|
||||||
@ -212,8 +205,7 @@ class ModularToolBar(QToolBar):
|
|||||||
action.add_to_toolbar(self, target_widget)
|
action.add_to_toolbar(self, target_widget)
|
||||||
self.widgets[action_id] = action
|
self.widgets[action_id] = action
|
||||||
|
|
||||||
def set_background_color(self, color: str):
|
def set_background_color(self):
|
||||||
self.setStyleSheet(f"QToolBar {{ background: {color}; }}")
|
|
||||||
self.setIconSize(QSize(20, 20))
|
self.setIconSize(QSize(20, 20))
|
||||||
self.setMovable(False)
|
self.setMovable(False)
|
||||||
self.setFloatable(False)
|
self.setFloatable(False)
|
||||||
|
@ -88,24 +88,26 @@ class BECWaveformWidget(BECWidget, QWidget):
|
|||||||
self.fig = BECFigure()
|
self.fig = BECFigure()
|
||||||
self.toolbar = ModularToolBar(
|
self.toolbar = ModularToolBar(
|
||||||
actions={
|
actions={
|
||||||
"save": IconAction(icon_path="save.svg", tooltip="Open Export Dialog"),
|
"save": MaterialIconAction(icon_name="save", tooltip="Open Export Dialog"),
|
||||||
"matplotlib": IconAction(
|
"matplotlib": MaterialIconAction(
|
||||||
icon_path="photo_library.svg", tooltip="Open Matplotlib Plot"
|
icon_name="photo_library", tooltip="Open Matplotlib Plot"
|
||||||
),
|
),
|
||||||
"separator_1": SeparatorAction(),
|
"separator_1": SeparatorAction(),
|
||||||
"drag_mode": IconAction(
|
"drag_mode": MaterialIconAction(
|
||||||
icon_path="drag_pan_mode.svg", tooltip="Drag Mouse Mode", checkable=True
|
icon_name="drag_pan", tooltip="Drag Mouse Mode", checkable=True
|
||||||
),
|
),
|
||||||
"rectangle_mode": IconAction(
|
"rectangle_mode": MaterialIconAction(
|
||||||
icon_path="rectangle_mode.svg", tooltip="Rectangle Zoom Mode", checkable=True
|
icon_name="frame_inspect", tooltip="Rectangle Zoom Mode", checkable=True
|
||||||
|
),
|
||||||
|
"auto_range": MaterialIconAction(
|
||||||
|
icon_name="open_in_full", tooltip="Autorange Plot"
|
||||||
),
|
),
|
||||||
"auto_range": IconAction(icon_path="auto_range.svg", tooltip="Autorange Plot"),
|
|
||||||
"separator_2": SeparatorAction(),
|
"separator_2": SeparatorAction(),
|
||||||
"curves": IconAction(
|
"curves": MaterialIconAction(
|
||||||
icon_path="line_axis.svg", tooltip="Open Curves Configuration"
|
icon_name="stacked_line_chart", tooltip="Open Curves Configuration"
|
||||||
),
|
),
|
||||||
"fit_params": IconAction(
|
"fit_params": MaterialIconAction(
|
||||||
icon_path="fitting_parameters.svg", tooltip="Open Fitting Parameters"
|
icon_name="monitoring", tooltip="Open Fitting Parameters"
|
||||||
),
|
),
|
||||||
"axis_settings": MaterialIconAction(
|
"axis_settings": MaterialIconAction(
|
||||||
icon_name="settings", tooltip="Open Configuration Dialog"
|
icon_name="settings", tooltip="Open Configuration Dialog"
|
||||||
@ -595,9 +597,13 @@ class BECWaveformWidget(BECWidget, QWidget):
|
|||||||
|
|
||||||
def main(): # pragma: no cover
|
def main(): # pragma: no cover
|
||||||
|
|
||||||
|
import bec_qthemes
|
||||||
|
from bec_qthemes._os_appearance.listener import OSThemeSwitchListener
|
||||||
from qtpy.QtWidgets import QApplication
|
from qtpy.QtWidgets import QApplication
|
||||||
|
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
|
bec_qthemes.setup_theme("auto")
|
||||||
|
|
||||||
widget = BECWaveformWidget()
|
widget = BECWaveformWidget()
|
||||||
widget.show()
|
widget.show()
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
||||||
|
Reference in New Issue
Block a user