bec-widgets 0.97.0__py3-none-any.whl → 0.99.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. CHANGELOG.md +48 -34
  2. PKG-INFO +1 -1
  3. bec_widgets/cli/client.py +10 -0
  4. bec_widgets/qt_utils/toolbar.py +24 -23
  5. bec_widgets/utils/colors.py +30 -6
  6. bec_widgets/widgets/dark_mode_button/__init__.py +0 -0
  7. bec_widgets/widgets/dark_mode_button/dark_mode_button.py +71 -0
  8. bec_widgets/widgets/dark_mode_button/dark_mode_button.pyproject +1 -0
  9. bec_widgets/widgets/dark_mode_button/dark_mode_button_plugin.py +54 -0
  10. bec_widgets/widgets/dark_mode_button/register_dark_mode_button.py +15 -0
  11. bec_widgets/widgets/dock/dock_area.py +46 -21
  12. bec_widgets/widgets/figure/figure.py +0 -1
  13. bec_widgets/widgets/image/image_widget.py +28 -28
  14. bec_widgets/widgets/motor_map/motor_map_widget.py +6 -4
  15. bec_widgets/widgets/positioner_box/positioner_box.py +6 -9
  16. bec_widgets/widgets/scan_control/scan_control.py +3 -1
  17. bec_widgets/widgets/toggle/toggle.py +5 -4
  18. bec_widgets/widgets/waveform/waveform_popups/curve_dialog/curve_dialog.py +4 -6
  19. bec_widgets/widgets/waveform/waveform_widget.py +18 -19
  20. {bec_widgets-0.97.0.dist-info → bec_widgets-0.99.0.dist-info}/METADATA +1 -1
  21. {bec_widgets-0.97.0.dist-info → bec_widgets-0.99.0.dist-info}/RECORD +29 -21
  22. docs/user/widgets/buttons/buttons.md +13 -0
  23. docs/user/widgets/buttons/dark_mode_disabled.png +0 -0
  24. docs/user/widgets/buttons/dark_mode_enabled.png +0 -0
  25. pyproject.toml +1 -1
  26. tests/unit_tests/test_dark_mode_button.py +70 -0
  27. {bec_widgets-0.97.0.dist-info → bec_widgets-0.99.0.dist-info}/WHEEL +0 -0
  28. {bec_widgets-0.97.0.dist-info → bec_widgets-0.99.0.dist-info}/entry_points.txt +0 -0
  29. {bec_widgets-0.97.0.dist-info → bec_widgets-0.99.0.dist-info}/licenses/LICENSE +0 -0
CHANGELOG.md CHANGED
@@ -1,5 +1,53 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v0.99.0 (2024-08-25)
4
+
5
+ ### Documentation
6
+
7
+ * docs(darkmodebutton): added dark mode button docs ([`406c263`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/406c263746f0e809c1a4d98356c48f40428c23d7))
8
+
9
+ ### Feature
10
+
11
+ * feat(darkmodebutton): added button to toggle between dark and light mode ([`cc8c166`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/cc8c166b5c1d37e0f64c83801b2347a54a6550b6))
12
+
13
+ ### Fix
14
+
15
+ * fix(toggle): emit state change ([`c4f3308`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/c4f3308dc0c3e4b2064760ccd7372d71b3e49f96))
16
+
17
+ ### Refactor
18
+
19
+ * refactor(darkmodebutton): renamed set_dark_mode_enabled to toggle_dark_mode ([`c70724a`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/c70724a456900bcb06b040407a2c5d497e49ce77))
20
+
21
+ ### Test
22
+
23
+ * test(dark_mode_button): added tests for dark mode button ([`df35aab`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/df35aabff30c5d00b1c441132bd370446653741e))
24
+
25
+ ## v0.98.0 (2024-08-25)
26
+
27
+ ### Feature
28
+
29
+ * feat(themes): added set_theme method ([`2b4449a`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/2b4449afebdda0a97f95712a1353cf40ec55c283))
30
+
31
+ ### Fix
32
+
33
+ * fix(toolbar): removed hardcoded color values ([`afdf4e8`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/afdf4e8782a22566932180224fa1c924d24c810f))
34
+
35
+ * fix: transitioning to material icons ([`2a82032`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/2a82032644a84e38df04e2035a6aa63f4a046360))
36
+
37
+ * fix(dock_area): transitioned to MaterialIconAction ([`88a2f66`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/88a2f667588e9aeb34ae556fa327898824052bc3))
38
+
39
+ * fix: fix color palette if qtheme was not called ([`3f3b207`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/3f3b207295ebd406ebaeecee465c774965161b8b))
40
+
41
+ * fix(figure): removed theme from figure init ([`e42b84c`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/e42b84c63650297d67feffccc02a2c2ba111ca79))
42
+
43
+ * fix: use globally set theme instead of the internal bec widgets theme ([`77c5aa7`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/77c5aa741cf1f5b969a42aa878aa2965176dbf41))
44
+
45
+ * fix(waveform): fixed icon appearance ([`36ad464`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/36ad4641594b67c9b789515c28f7db78a12757ee))
46
+
47
+ ### Refactor
48
+
49
+ * refactor(waveform): use set theme for demo ([`44cfda1`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/44cfda1c07306669c9a4e09706d95e6b91dee370))
50
+
3
51
  ## v0.97.0 (2024-08-23)
4
52
 
5
53
  ### Feature
@@ -123,37 +171,3 @@ Since we now rely on reusing the BECClient singleton, we need the fix introduced
123
171
  ### Fix
124
172
 
125
173
  * fix(rpc): use client singleton instead of dispatcher ([`ea9240d`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/ea9240d2f71931082f33fb6b68231469875c3d63))
126
-
127
- * fix: removed qcoreapplication for polling events ([`4d02b42`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/4d02b42f11e9882b843317255a4975565c8a536f))
128
-
129
- ## v0.94.4 (2024-08-14)
130
-
131
- ### Documentation
132
-
133
- * docs: review developer section; add introduction ([`2af5c94`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/2af5c94913a3435c1839034df4f45f885b56d08b))
134
-
135
- ### Fix
136
-
137
- * fix: do not shutdown client in "close"
138
-
139
- Terminating client connections has to be done at the application level ([`198c1d1`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/198c1d1064cc2dae55de4b941929341faddacb28))
140
-
141
- ## v0.94.3 (2024-08-13)
142
-
143
- ### Fix
144
-
145
- * fix(curve_dialog): async curves are shown in curve dialog after addition. ([`7aeb2b5`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/7aeb2b5c26c7c2851e8d663d32521da8daec95ef))
146
-
147
- * fix(waveform): async device entry is correctly passed, updated and with new scan the previous data are cleared ([`d56ea95`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/d56ea95ef97bfdd0bc3eeddc4505d20b38e28559))
148
-
149
- ### Test
150
-
151
- * test(waveform_widget): added tests for axis setting and curve dialog ([`f285b35`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/f285b35b491660549e74349318119f7c2c44f619))
152
-
153
- ## v0.94.2 (2024-08-13)
154
-
155
- ### Fix
156
-
157
- * fix(image): image is single image mode do not raise popup error when connected twice with the same monitor ([`98b79aa`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/98b79aac7b47b73137f4d582f7f1d552b1d95366))
158
-
159
- ## v0.94.1 (2024-08-12)
PKG-INFO CHANGED
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: bec_widgets
3
- Version: 0.97.0
3
+ Version: 0.99.0
4
4
  Summary: BEC Widgets
5
5
  Project-URL: Bug Tracker, https://gitlab.psi.ch/bec/bec_widgets/issues
6
6
  Project-URL: Homepage, https://gitlab.psi.ch/bec/bec_widgets
bec_widgets/cli/client.py CHANGED
@@ -21,6 +21,7 @@ class Widgets(str, enum.Enum):
21
21
  BECQueue = "BECQueue"
22
22
  BECStatusBox = "BECStatusBox"
23
23
  BECWaveformWidget = "BECWaveformWidget"
24
+ DarkModeButton = "DarkModeButton"
24
25
  DeviceBrowser = "DeviceBrowser"
25
26
  DeviceComboBox = "DeviceComboBox"
26
27
  DeviceLineEdit = "DeviceLineEdit"
@@ -2289,6 +2290,15 @@ class BECWaveformWidget(RPCBase):
2289
2290
  """
2290
2291
 
2291
2292
 
2293
+ class DarkModeButton(RPCBase):
2294
+ @rpc_call
2295
+ def toggle_dark_mode(self) -> None:
2296
+ """
2297
+ Toggle the dark mode state. This will change the theme of the entire
2298
+ application to dark or light mode.
2299
+ """
2300
+
2301
+
2292
2302
  class DeviceBrowser(RPCBase):
2293
2303
  @property
2294
2304
  @rpc_call
@@ -76,31 +76,38 @@ class MaterialIconAction:
76
76
  Action with a Material icon for the toolbar.
77
77
 
78
78
  Args:
79
- icon_path (str, optional): The name of the icon file from `assets/toolbar_icons`. Defaults to None.
79
+ icon_path (str, optional): The name of the Material icon. Defaults to None.
80
80
  tooltip (bool, optional): The tooltip for the action. Defaults to None.
81
81
  checkable (bool, optional): Whether the action is checkable. Defaults to False.
82
+ filled (bool, optional): Whether the icon is filled. Defaults to False.
82
83
  """
83
84
 
84
- def __init__(self, icon_name: str = None, tooltip: str = None, checkable: bool = False):
85
+ def __init__(
86
+ self,
87
+ icon_name: str = None,
88
+ tooltip: str = None,
89
+ checkable: bool = False,
90
+ filled: bool = False,
91
+ ):
85
92
  self.icon_name = icon_name
86
93
  self.tooltip = tooltip
87
94
  self.checkable = checkable
88
95
  self.action = None
96
+ self.filled = filled
89
97
 
90
98
  def add_to_toolbar(self, toolbar: QToolBar, target: QWidget):
91
- color = {
92
- "dark": "#FFFFFF",
93
- "light": "#000000",
94
- } # FIXME: This should be a theme color but the toolbar doesn't respect the theme atm
95
- # once fixed, change it to
96
- # palette = QGuiApplication.palette()
97
- # palette.toolTipBase().color()
98
-
99
- icon = material_icon(self.icon_name, size=(20, 20), color=color, convert_to_pixmap=False)
99
+ icon = self.get_icon()
100
100
  self.action = QAction(icon, self.tooltip, target)
101
101
  self.action.setCheckable(self.checkable)
102
102
  toolbar.addAction(self.action)
103
103
 
104
+ def get_icon(self):
105
+
106
+ icon = material_icon(
107
+ self.icon_name, size=(20, 20), convert_to_pixmap=False, filled=self.filled
108
+ )
109
+ return icon
110
+
104
111
 
105
112
  class DeviceSelectionAction(ToolBarAction):
106
113
  """
@@ -165,10 +172,12 @@ class ExpandableMenuAction(ToolBarAction):
165
172
  menu = QMenu(button)
166
173
  for action_id, action in self.actions.items():
167
174
  sub_action = QAction(action.tooltip, target)
168
- if action.icon_path:
175
+ if hasattr(action, "icon_path"):
169
176
  icon = QIcon()
170
177
  icon.addFile(action.icon_path, size=QSize(20, 20))
171
178
  sub_action.setIcon(icon)
179
+ elif hasattr(action, "get_icon"):
180
+ sub_action.setIcon(action.get_icon())
172
181
  sub_action.setCheckable(action.checkable)
173
182
  menu.addAction(sub_action)
174
183
  self.widgets[action_id] = sub_action
@@ -182,20 +191,13 @@ class ModularToolBar(QToolBar):
182
191
  parent (QWidget, optional): The parent widget of the toolbar. Defaults to None.
183
192
  actions (list[ToolBarAction], optional): A list of action creators to populate the toolbar. Defaults to None.
184
193
  target_widget (QWidget, optional): The widget that the actions will target. Defaults to None.
185
- color (str, optional): The background color of the toolbar. Defaults to "black".
186
194
  """
187
195
 
188
- def __init__(
189
- self,
190
- parent=None,
191
- actions: dict | None = None,
192
- target_widget=None,
193
- color: str = "rgba(255, 255, 255, 0)",
194
- ):
196
+ def __init__(self, parent=None, actions: dict | None = None, target_widget=None):
195
197
  super().__init__(parent)
196
198
 
197
199
  self.widgets = defaultdict(dict)
198
- self.set_background_color(color)
200
+ self.set_background_color()
199
201
 
200
202
  if actions is not None and target_widget is not None:
201
203
  self.populate_toolbar(actions, target_widget)
@@ -212,8 +214,7 @@ class ModularToolBar(QToolBar):
212
214
  action.add_to_toolbar(self, target_widget)
213
215
  self.widgets[action_id] = action
214
216
 
215
- def set_background_color(self, color: str):
216
- self.setStyleSheet(f"QToolBar {{ background: {color}; }}")
217
+ def set_background_color(self):
217
218
  self.setIconSize(QSize(20, 20))
218
219
  self.setMovable(False)
219
220
  self.setFloatable(False)
@@ -5,21 +5,45 @@ from typing import Literal
5
5
  import bec_qthemes
6
6
  import numpy as np
7
7
  import pyqtgraph as pg
8
+ from bec_qthemes._os_appearance.listener import OSThemeSwitchListener
8
9
  from pydantic_core import PydanticCustomError
9
10
  from qtpy.QtGui import QColor
10
11
  from qtpy.QtWidgets import QApplication
11
12
 
12
- CURRENT_THEME = "dark"
13
-
14
13
 
15
14
  def get_theme_palette():
16
- return bec_qthemes.load_palette(CURRENT_THEME)
15
+ if QApplication.instance() is None or not hasattr(QApplication.instance(), "theme"):
16
+ theme = "dark"
17
+ else:
18
+ theme = QApplication.instance().theme["theme"]
19
+ return bec_qthemes.load_palette(theme)
17
20
 
18
21
 
19
- def apply_theme(theme: Literal["dark", "light"]):
20
- global CURRENT_THEME
21
- CURRENT_THEME = theme
22
+ def set_theme(theme: Literal["dark", "light", "auto"]):
23
+ """
24
+ Set the theme for the application.
25
+
26
+ Args:
27
+ theme (Literal["dark", "light", "auto"]): The theme to set. "auto" will automatically switch between dark and light themes based on the system theme.
28
+ """
29
+ app = QApplication.instance()
30
+ bec_qthemes.setup_theme(theme)
31
+ pg.setConfigOption("background", "w" if app.theme["theme"] == "light" else "k")
32
+
33
+ # pylint: disable=protected-access
34
+ if theme != "auto":
35
+ return
22
36
 
37
+ def callback():
38
+ app.theme["theme"] = listener._theme.lower()
39
+ apply_theme(listener._theme.lower())
40
+
41
+ listener = OSThemeSwitchListener(callback)
42
+
43
+ app.installEventFilter(listener)
44
+
45
+
46
+ def apply_theme(theme: Literal["dark", "light"]):
23
47
  app = QApplication.instance()
24
48
  # go through all pyqtgraph widgets and set background
25
49
  children = itertools.chain.from_iterable(
File without changes
@@ -0,0 +1,71 @@
1
+ from bec_qthemes import material_icon
2
+ from qtpy.QtCore import Property, Qt, Slot
3
+ from qtpy.QtWidgets import QHBoxLayout, QPushButton, QWidget
4
+
5
+ from bec_widgets.utils.bec_widget import BECWidget
6
+ from bec_widgets.utils.colors import set_theme
7
+
8
+
9
+ class DarkModeButton(BECWidget, QWidget):
10
+ USER_ACCESS = ["toggle_dark_mode"]
11
+
12
+ def __init__(
13
+ self, parent: QWidget | None = None, client=None, gui_id: str | None = None
14
+ ) -> None:
15
+ super().__init__(client=client, gui_id=gui_id)
16
+ QWidget.__init__(self, parent)
17
+
18
+ self._dark_mode_enabled = False
19
+ self.layout = QHBoxLayout(self)
20
+ self.layout.setSpacing(0)
21
+ self.layout.setContentsMargins(0, 0, 0, 0)
22
+ self.layout.setAlignment(Qt.AlignmentFlag.AlignVCenter)
23
+
24
+ icon = material_icon("dark_mode", size=(20, 20), convert_to_pixmap=False)
25
+ self.mode_button = QPushButton(icon=icon)
26
+ self.update_mode_button()
27
+ self.mode_button.clicked.connect(self.toggle_dark_mode)
28
+ self.layout.addWidget(self.mode_button)
29
+ self.setLayout(self.layout)
30
+ self.setFixedSize(40, 40)
31
+
32
+ @Property(bool)
33
+ def dark_mode_enabled(self) -> bool:
34
+ """
35
+ The dark mode state. If True, dark mode is enabled. If False, light mode is enabled.
36
+ """
37
+ return self._dark_mode_enabled
38
+
39
+ @dark_mode_enabled.setter
40
+ def dark_mode_enabled(self, state: bool) -> None:
41
+ self._dark_mode_enabled = state
42
+
43
+ @Slot()
44
+ def toggle_dark_mode(self) -> None:
45
+ """
46
+ Toggle the dark mode state. This will change the theme of the entire
47
+ application to dark or light mode.
48
+ """
49
+ self.dark_mode_enabled = not self.dark_mode_enabled
50
+ self.update_mode_button()
51
+ set_theme("dark" if self.dark_mode_enabled else "light")
52
+
53
+ def update_mode_button(self):
54
+ icon = material_icon(
55
+ "light_mode" if self.dark_mode_enabled else "dark_mode",
56
+ size=(20, 20),
57
+ convert_to_pixmap=False,
58
+ )
59
+ self.mode_button.setIcon(icon)
60
+ self.mode_button.setToolTip("Set Light Mode" if self.dark_mode_enabled else "Set Dark Mode")
61
+
62
+
63
+ if __name__ == "__main__":
64
+ from qtpy.QtWidgets import QApplication
65
+
66
+ app = QApplication([])
67
+
68
+ w = DarkModeButton()
69
+ w.show()
70
+
71
+ app.exec_()
@@ -0,0 +1 @@
1
+ {'files': ['dark_mode_button.py']}
@@ -0,0 +1,54 @@
1
+ # Copyright (C) 2022 The Qt Company Ltd.
2
+ # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
+
4
+ from qtpy.QtDesigner import QDesignerCustomWidgetInterface
5
+
6
+ from bec_widgets.utils.bec_designer import designer_material_icon
7
+ from bec_widgets.widgets.dark_mode_button.dark_mode_button import DarkModeButton
8
+
9
+ DOM_XML = """
10
+ <ui language='c++'>
11
+ <widget class='DarkModeButton' name='dark_mode_button'>
12
+ </widget>
13
+ </ui>
14
+ """
15
+
16
+
17
+ class DarkModeButtonPlugin(QDesignerCustomWidgetInterface): # pragma: no cover
18
+ def __init__(self):
19
+ super().__init__()
20
+ self._form_editor = None
21
+
22
+ def createWidget(self, parent):
23
+ t = DarkModeButton(parent)
24
+ return t
25
+
26
+ def domXml(self):
27
+ return DOM_XML
28
+
29
+ def group(self):
30
+ return "BEC Buttons"
31
+
32
+ def icon(self):
33
+ return designer_material_icon("dark_mode")
34
+
35
+ def includeFile(self):
36
+ return "dark_mode_button"
37
+
38
+ def initialize(self, form_editor):
39
+ self._form_editor = form_editor
40
+
41
+ def isContainer(self):
42
+ return False
43
+
44
+ def isInitialized(self):
45
+ return self._form_editor is not None
46
+
47
+ def name(self):
48
+ return "DarkModeButton"
49
+
50
+ def toolTip(self):
51
+ return "Button to toggle between dark and light mode."
52
+
53
+ def whatsThis(self):
54
+ return self.toolTip()
@@ -0,0 +1,15 @@
1
+ def main(): # pragma: no cover
2
+ from qtpy import PYSIDE6
3
+
4
+ if not PYSIDE6:
5
+ print("PYSIDE6 is not available in the environment. Cannot patch designer.")
6
+ return
7
+ from PySide6.QtDesigner import QPyDesignerCustomWidgetCollection
8
+
9
+ from bec_widgets.widgets.dark_mode_button.dark_mode_button_plugin import DarkModeButtonPlugin
10
+
11
+ QPyDesignerCustomWidgetCollection.addCustomWidget(DarkModeButtonPlugin())
12
+
13
+
14
+ if __name__ == "__main__": # pragma: no cover
15
+ main()
@@ -9,17 +9,16 @@ from qtpy.QtCore import Qt
9
9
  from qtpy.QtGui import QPainter, QPaintEvent
10
10
  from qtpy.QtWidgets import QVBoxLayout, QWidget
11
11
 
12
+ from bec_widgets.qt_utils.error_popups import SafeSlot
12
13
  from bec_widgets.qt_utils.toolbar import (
13
14
  ExpandableMenuAction,
14
- IconAction,
15
+ MaterialIconAction,
15
16
  ModularToolBar,
16
17
  SeparatorAction,
17
18
  )
18
19
  from bec_widgets.utils import ConnectionConfig, WidgetContainerUtils
19
20
  from bec_widgets.utils.bec_widget import BECWidget
20
-
21
- from ...qt_utils.error_popups import SafeSlot
22
- from .dock import BECDock, DockConfig
21
+ from bec_widgets.widgets.dock.dock import BECDock, DockConfig
23
22
 
24
23
 
25
24
  class DockAreaConfig(ConnectionConfig):
@@ -71,20 +70,26 @@ class BECDockArea(BECWidget, QWidget):
71
70
  "menu_plots": ExpandableMenuAction(
72
71
  label="Add Plot ",
73
72
  actions={
74
- "waveform": IconAction(icon_path="waveform.svg", tooltip="Add Waveform"),
75
- "image": IconAction(icon_path="image.svg", tooltip="Add Image"),
76
- "motor_map": IconAction(icon_path="motor_map.svg", tooltip="Add Motor Map"),
73
+ "waveform": MaterialIconAction(
74
+ icon_name="show_chart", tooltip="Add Waveform", filled=True
75
+ ),
76
+ "image": MaterialIconAction(
77
+ icon_name="image", tooltip="Add Image", filled=True
78
+ ),
79
+ "motor_map": MaterialIconAction(
80
+ icon_name="my_location", tooltip="Add Motor Map", filled=True
81
+ ),
77
82
  },
78
83
  ),
79
84
  "separator_0": SeparatorAction(),
80
85
  "menu_devices": ExpandableMenuAction(
81
86
  label="Add Device Control ",
82
87
  actions={
83
- "scan_control": IconAction(
84
- icon_path="scan_control.svg", tooltip="Add Scan Control"
88
+ "scan_control": MaterialIconAction(
89
+ icon_name="stacked_line_chart", tooltip="Add Scan Control", filled=True
85
90
  ),
86
- "positioner_box": IconAction(
87
- icon_path="positioner_box.svg", tooltip="Add Device Box"
91
+ "positioner_box": MaterialIconAction(
92
+ icon_name="switch_right", tooltip="Add Device Box", filled=True
88
93
  ),
89
94
  },
90
95
  ),
@@ -92,21 +97,29 @@ class BECDockArea(BECWidget, QWidget):
92
97
  "menu_utils": ExpandableMenuAction(
93
98
  label="Add Utils ",
94
99
  actions={
95
- "queue": IconAction(icon_path="queue.svg", tooltip="Add Scan Queue"),
96
- "vs_code": IconAction(icon_path="terminal.svg", tooltip="Add VS Code"),
97
- "status": IconAction(icon_path="status.svg", tooltip="Add BEC Status Box"),
98
- "progress_bar": IconAction(
99
- icon_path="ring_progress.svg", tooltip="Add Circular ProgressBar"
100
+ "queue": MaterialIconAction(
101
+ icon_name="edit_note", tooltip="Add Scan Queue", filled=True
102
+ ),
103
+ "vs_code": MaterialIconAction(
104
+ icon_name="show_chart", tooltip="Add VS Code", filled=True
105
+ ),
106
+ "status": MaterialIconAction(
107
+ icon_name="dns", tooltip="Add BEC Status Box", filled=True
108
+ ),
109
+ "progress_bar": MaterialIconAction(
110
+ icon_name="track_changes",
111
+ tooltip="Add Circular ProgressBar",
112
+ filled=True,
100
113
  ),
101
114
  },
102
115
  ),
103
116
  "separator_2": SeparatorAction(),
104
- "attach_all": IconAction(
105
- icon_path="attach_all.svg", tooltip="Attach all floating docks"
117
+ "attach_all": MaterialIconAction(
118
+ icon_name="zoom_in_map", tooltip="Attach all floating docks"
106
119
  ),
107
- "save_state": IconAction(icon_path="save_state.svg", tooltip="Save Dock State"),
108
- "restore_state": IconAction(
109
- icon_path="restore_state.svg", tooltip="Restore Dock State"
120
+ "save_state": MaterialIconAction(icon_name="bookmark", tooltip="Save Dock State"),
121
+ "restore_state": MaterialIconAction(
122
+ icon_name="frame_reload", tooltip="Restore Dock State"
110
123
  ),
111
124
  },
112
125
  target_widget=self,
@@ -368,3 +381,15 @@ class BECDockArea(BECWidget, QWidget):
368
381
  """
369
382
  self.cleanup()
370
383
  super().close()
384
+
385
+
386
+ if __name__ == "__main__":
387
+ from qtpy.QtWidgets import QApplication
388
+
389
+ from bec_widgets.utils.colors import set_theme
390
+
391
+ app = QApplication([])
392
+ set_theme("auto")
393
+ dock_area = BECDockArea()
394
+ dock_area.show()
395
+ app.exec_()
@@ -182,7 +182,6 @@ class BECFigure(BECWidget, pg.GraphicsLayoutWidget):
182
182
  print(f"Error in applying config: {e}")
183
183
  return
184
184
  self.config = config
185
- self.change_theme(self.config.theme)
186
185
 
187
186
  # widget_config has to be reset for not have each widget config twice when added to the figure
188
187
  widget_configs = list(self.config.widgets.values())
@@ -10,7 +10,7 @@ from bec_widgets.qt_utils.error_popups import SafeSlot, WarningPopupUtility
10
10
  from bec_widgets.qt_utils.settings_dialog import SettingsDialog
11
11
  from bec_widgets.qt_utils.toolbar import (
12
12
  DeviceSelectionAction,
13
- IconAction,
13
+ MaterialIconAction,
14
14
  ModularToolBar,
15
15
  SeparatorAction,
16
16
  )
@@ -66,45 +66,45 @@ class BECImageWidget(BECWidget, QWidget):
66
66
  "monitor": DeviceSelectionAction(
67
67
  "Monitor:", DeviceComboBox(device_filter="Device")
68
68
  ),
69
- "connect": IconAction(icon_path="connection.svg", tooltip="Connect Device"),
69
+ "connect": MaterialIconAction(icon_name="link", tooltip="Connect Device"),
70
70
  "separator_0": SeparatorAction(),
71
- "save": IconAction(icon_path="save.svg", tooltip="Open Export Dialog"),
71
+ "save": MaterialIconAction(icon_name="save", tooltip="Open Export Dialog"),
72
72
  "separator_1": SeparatorAction(),
73
- "drag_mode": IconAction(
74
- icon_path="drag_pan_mode.svg", tooltip="Drag Mouse Mode", checkable=True
73
+ "drag_mode": MaterialIconAction(
74
+ icon_name="open_with", tooltip="Drag Mouse Mode", checkable=True
75
75
  ),
76
- "rectangle_mode": IconAction(
77
- icon_path="rectangle_mode.svg", tooltip="Rectangle Zoom Mode", checkable=True
76
+ "rectangle_mode": MaterialIconAction(
77
+ icon_name="frame_inspect", tooltip="Rectangle Zoom Mode", checkable=True
78
78
  ),
79
- "auto_range": IconAction(icon_path="auto_range.svg", tooltip="Autorange Plot"),
80
- "auto_range_image": IconAction(
81
- icon_path="image_autorange.svg",
82
- tooltip="Autorange Image Intensity",
83
- checkable=True,
79
+ "auto_range": MaterialIconAction(
80
+ icon_name="open_in_full", tooltip="Autorange Plot"
84
81
  ),
85
- "aspect_ratio": IconAction(
86
- icon_path="lock_aspect_ratio.svg",
87
- tooltip="Lock image aspect ratio",
88
- checkable=True,
82
+ "auto_range_image": MaterialIconAction(
83
+ icon_name="hdr_auto", tooltip="Autorange Image Intensity", checkable=True
84
+ ),
85
+ "aspect_ratio": MaterialIconAction(
86
+ icon_name="aspect_ratio", tooltip="Lock image aspect ratio", checkable=True
89
87
  ),
90
88
  "separator_2": SeparatorAction(),
91
- "FFT": IconAction(icon_path="fft.svg", tooltip="Toggle FFT", checkable=True),
92
- "log": IconAction(
93
- icon_path="log_scale.png", tooltip="Toggle log scale", checkable=True
89
+ "FFT": MaterialIconAction(icon_name="fft", tooltip="Toggle FFT", checkable=True),
90
+ "log": MaterialIconAction(
91
+ icon_name="log_scale", tooltip="Toggle log scale", checkable=True
92
+ ),
93
+ "transpose": MaterialIconAction(
94
+ icon_name="transform", tooltip="Transpose Image", checkable=True
94
95
  ),
95
- "transpose": IconAction(
96
- icon_path="transform.svg", tooltip="Transpose Image", checkable=True
96
+ "rotate_right": MaterialIconAction(
97
+ icon_name="rotate_right", tooltip="Rotate image clockwise by 90 deg"
97
98
  ),
98
- "rotate_right": IconAction(
99
- icon_path="rotate_right.svg", tooltip="Rotate image clockwise by 90 deg"
99
+ "rotate_left": MaterialIconAction(
100
+ icon_name="rotate_left", tooltip="Rotate image counterclockwise by 90 deg"
100
101
  ),
101
- "rotate_left": IconAction(
102
- icon_path="rotate_left.svg", tooltip="Rotate image counterclockwise by 90 deg"
102
+ "reset": MaterialIconAction(
103
+ icon_name="reset_settings", tooltip="Reset Image Settings"
103
104
  ),
104
- "reset": IconAction(icon_path="reset_settings.svg", tooltip="Reset Image Settings"),
105
105
  "separator_3": SeparatorAction(),
106
- "axis_settings": IconAction(
107
- icon_path="settings.svg", tooltip="Open Configuration Dialog"
106
+ "axis_settings": MaterialIconAction(
107
+ icon_name="settings", tooltip="Open Configuration Dialog"
108
108
  ),
109
109
  },
110
110
  target_widget=self,
@@ -5,7 +5,7 @@ import sys
5
5
  from qtpy.QtWidgets import QVBoxLayout, QWidget
6
6
 
7
7
  from bec_widgets.qt_utils.settings_dialog import SettingsDialog
8
- from bec_widgets.qt_utils.toolbar import DeviceSelectionAction, IconAction, ModularToolBar
8
+ from bec_widgets.qt_utils.toolbar import DeviceSelectionAction, MaterialIconAction, ModularToolBar
9
9
  from bec_widgets.utils.bec_widget import BECWidget
10
10
  from bec_widgets.widgets.device_combobox.device_combobox import DeviceComboBox
11
11
  from bec_widgets.widgets.figure import BECFigure
@@ -54,9 +54,11 @@ class BECMotorMapWidget(BECWidget, QWidget):
54
54
  "motor_y": DeviceSelectionAction(
55
55
  "Motor Y:", DeviceComboBox(device_filter="Positioner")
56
56
  ),
57
- "connect": IconAction(icon_path="connection.svg", tooltip="Connect Motors"),
58
- "history": IconAction(icon_path="history.svg", tooltip="Reset Trace History"),
59
- "config": IconAction(icon_path="settings.svg", tooltip="Open Configuration Dialog"),
57
+ "connect": MaterialIconAction(icon_name="link", tooltip="Connect Motors"),
58
+ "history": MaterialIconAction(icon_name="history", tooltip="Reset Trace History"),
59
+ "config": MaterialIconAction(
60
+ icon_name="settings", tooltip="Open Configuration Dialog"
61
+ ),
60
62
  },
61
63
  target_widget=self,
62
64
  )
@@ -7,13 +7,14 @@ from bec_lib.device import Positioner
7
7
  from bec_lib.endpoints import MessageEndpoints
8
8
  from bec_lib.logger import bec_logger
9
9
  from bec_lib.messages import ScanQueueMessage
10
- from qtpy.QtCore import Property, QSize, Signal, Slot
11
- from qtpy.QtGui import QDoubleValidator, QIcon
10
+ from bec_qthemes import material_icon
11
+ from qtpy.QtCore import Property, Signal, Slot
12
+ from qtpy.QtGui import QDoubleValidator
12
13
  from qtpy.QtWidgets import QDialog, QDoubleSpinBox, QPushButton, QVBoxLayout, QWidget
13
14
 
14
15
  from bec_widgets.utils import UILoader
15
16
  from bec_widgets.utils.bec_widget import BECWidget
16
- from bec_widgets.utils.colors import apply_theme
17
+ from bec_widgets.utils.colors import set_theme
17
18
  from bec_widgets.widgets.device_line_edit.device_line_edit import DeviceLineEdit
18
19
 
19
20
  logger = bec_logger.logger
@@ -78,11 +79,7 @@ class PositionerBox(BECWidget, QWidget):
78
79
  self.ui.setpoint.setValidator(self.setpoint_validator)
79
80
  self.ui.spinner_widget.start()
80
81
  self.ui.tool_button.clicked.connect(self._open_dialog_selection)
81
- icon = QIcon()
82
- icon.addFile(
83
- os.path.join(MODULE_PATH, "assets", "toolbar_icons", "device_line_edit.svg"),
84
- size=QSize(16, 16),
85
- )
82
+ icon = material_icon(icon_name="edit_note", size=(16, 16), convert_to_pixmap=False)
86
83
  self.ui.tool_button.setIcon(icon)
87
84
 
88
85
  def _open_dialog_selection(self):
@@ -303,7 +300,7 @@ if __name__ == "__main__": # pragma: no cover
303
300
  from qtpy.QtWidgets import QApplication
304
301
 
305
302
  app = QApplication(sys.argv)
306
- apply_theme("dark")
303
+ set_theme("dark")
307
304
  widget = PositionerBox(device="bpm4i")
308
305
 
309
306
  widget.show()
@@ -260,10 +260,12 @@ class ScanControl(BECWidget, QWidget):
260
260
 
261
261
  # Application example
262
262
  if __name__ == "__main__": # pragma: no cover
263
+ from bec_widgets.utils.colors import set_theme
264
+
263
265
  app = QApplication([])
264
266
  scan_control = ScanControl()
265
267
 
266
- apply_theme("dark")
268
+ set_theme("auto")
267
269
  window = scan_control
268
270
  window.show()
269
271
  app.exec()
@@ -1,6 +1,6 @@
1
1
  import sys
2
2
 
3
- from qtpy.QtCore import Property, QEasingCurve, QPointF, QPropertyAnimation, Qt
3
+ from qtpy.QtCore import Property, QEasingCurve, QPointF, QPropertyAnimation, Qt, Signal
4
4
  from qtpy.QtGui import QColor, QPainter
5
5
  from qtpy.QtWidgets import QApplication, QWidget
6
6
 
@@ -10,6 +10,8 @@ class ToggleSwitch(QWidget):
10
10
  A simple toggle.
11
11
  """
12
12
 
13
+ enabled = Signal(bool)
14
+
13
15
  def __init__(self, parent=None):
14
16
  super().__init__(parent)
15
17
  self.setFixedSize(40, 21)
@@ -41,6 +43,7 @@ class ToggleSwitch(QWidget):
41
43
  self._checked = state
42
44
  self.update_colors()
43
45
  self.set_thumb_pos_to_state()
46
+ self.enabled.emit(self._checked)
44
47
 
45
48
  @Property(QPointF)
46
49
  def thumb_pos(self):
@@ -109,9 +112,7 @@ class ToggleSwitch(QWidget):
109
112
 
110
113
  def mousePressEvent(self, event):
111
114
  if event.button() == Qt.LeftButton:
112
- self._checked = not self._checked
113
- self.update_colors()
114
- self.animate_thumb()
115
+ self.checked = not self.checked
115
116
 
116
117
  def update_colors(self):
117
118
 
@@ -3,6 +3,7 @@ from __future__ import annotations
3
3
  import os
4
4
  from typing import Literal
5
5
 
6
+ from bec_qthemes import material_icon
6
7
  from pydantic import BaseModel
7
8
  from qtpy.QtCore import QObject, QSize, Slot
8
9
  from qtpy.QtGui import QIcon
@@ -38,10 +39,7 @@ class CurveSettings(SettingWidget):
38
39
  self.ui.normalize_colors_dap.clicked.connect(lambda: self.change_colormap("dap"))
39
40
 
40
41
  def _setup_icons(self):
41
- add_icon = QIcon()
42
- add_icon.addFile(
43
- os.path.join(MODULE_PATH, "assets", "toolbar_icons", "add.svg"), size=QSize(20, 20)
44
- )
42
+ add_icon = material_icon(icon_name="add", size=(20, 20), convert_to_pixmap=False)
45
43
  self.ui.add_dap.setIcon(add_icon)
46
44
  self.ui.add_dap.setToolTip("Add DAP Curve")
47
45
  self.ui.add_curve.setIcon(add_icon)
@@ -339,5 +337,5 @@ class StyleComboBox(QComboBox):
339
337
  class RemoveButton(QPushButton):
340
338
  def __init__(self, parent=None):
341
339
  super().__init__(parent)
342
- icon_path = os.path.join(MODULE_PATH, "assets", "toolbar_icons", "remove.svg")
343
- self.setIcon(QIcon(icon_path))
340
+ icon = material_icon("disabled_by_default", size=(20, 20), convert_to_pixmap=False)
341
+ self.setIcon(icon)
@@ -10,12 +10,7 @@ from qtpy.QtWidgets import QVBoxLayout, QWidget
10
10
 
11
11
  from bec_widgets.qt_utils.error_popups import SafeSlot, WarningPopupUtility
12
12
  from bec_widgets.qt_utils.settings_dialog import SettingsDialog
13
- from bec_widgets.qt_utils.toolbar import (
14
- IconAction,
15
- MaterialIconAction,
16
- ModularToolBar,
17
- SeparatorAction,
18
- )
13
+ from bec_widgets.qt_utils.toolbar import MaterialIconAction, ModularToolBar, SeparatorAction
19
14
  from bec_widgets.utils.bec_widget import BECWidget
20
15
  from bec_widgets.widgets.figure import BECFigure
21
16
  from bec_widgets.widgets.figure.plots.axis_settings import AxisSettings
@@ -88,24 +83,26 @@ class BECWaveformWidget(BECWidget, QWidget):
88
83
  self.fig = BECFigure()
89
84
  self.toolbar = ModularToolBar(
90
85
  actions={
91
- "save": IconAction(icon_path="save.svg", tooltip="Open Export Dialog"),
92
- "matplotlib": IconAction(
93
- icon_path="photo_library.svg", tooltip="Open Matplotlib Plot"
86
+ "save": MaterialIconAction(icon_name="save", tooltip="Open Export Dialog"),
87
+ "matplotlib": MaterialIconAction(
88
+ icon_name="photo_library", tooltip="Open Matplotlib Plot"
94
89
  ),
95
90
  "separator_1": SeparatorAction(),
96
- "drag_mode": IconAction(
97
- icon_path="drag_pan_mode.svg", tooltip="Drag Mouse Mode", checkable=True
91
+ "drag_mode": MaterialIconAction(
92
+ icon_name="drag_pan", tooltip="Drag Mouse Mode", checkable=True
93
+ ),
94
+ "rectangle_mode": MaterialIconAction(
95
+ icon_name="frame_inspect", tooltip="Rectangle Zoom Mode", checkable=True
98
96
  ),
99
- "rectangle_mode": IconAction(
100
- icon_path="rectangle_mode.svg", tooltip="Rectangle Zoom Mode", checkable=True
97
+ "auto_range": MaterialIconAction(
98
+ icon_name="open_in_full", tooltip="Autorange Plot"
101
99
  ),
102
- "auto_range": IconAction(icon_path="auto_range.svg", tooltip="Autorange Plot"),
103
100
  "separator_2": SeparatorAction(),
104
- "curves": IconAction(
105
- icon_path="line_axis.svg", tooltip="Open Curves Configuration"
101
+ "curves": MaterialIconAction(
102
+ icon_name="stacked_line_chart", tooltip="Open Curves Configuration"
106
103
  ),
107
- "fit_params": IconAction(
108
- icon_path="fitting_parameters.svg", tooltip="Open Fitting Parameters"
104
+ "fit_params": MaterialIconAction(
105
+ icon_name="monitoring", tooltip="Open Fitting Parameters"
109
106
  ),
110
107
  "axis_settings": MaterialIconAction(
111
108
  icon_name="settings", tooltip="Open Configuration Dialog"
@@ -594,10 +591,12 @@ class BECWaveformWidget(BECWidget, QWidget):
594
591
 
595
592
 
596
593
  def main(): # pragma: no cover
597
-
598
594
  from qtpy.QtWidgets import QApplication
599
595
 
596
+ from bec_widgets.utils.colors import set_theme
597
+
600
598
  app = QApplication(sys.argv)
599
+ set_theme("auto")
601
600
  widget = BECWaveformWidget()
602
601
  widget.show()
603
602
  sys.exit(app.exec_())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: bec_widgets
3
- Version: 0.97.0
3
+ Version: 0.99.0
4
4
  Summary: BEC Widgets
5
5
  Project-URL: Bug Tracker, https://gitlab.psi.ch/bec/bec_widgets/issues
6
6
  Project-URL: Homepage, https://gitlab.psi.ch/bec/bec_widgets
@@ -2,11 +2,11 @@
2
2
  .gitlab-ci.yml,sha256=9dZ_EvimZrDzG8MtII0qtBYMM_Nc6xqh2iFRds0rlvE,8370
3
3
  .pylintrc,sha256=eeY8YwSI74oFfq6IYIbCqnx3Vk8ZncKaatv96n_Y8Rs,18544
4
4
  .readthedocs.yaml,sha256=aSOc277LqXcsTI6lgvm_JY80lMlr69GbPKgivua2cS0,603
5
- CHANGELOG.md,sha256=F5JNzWDV1tskuAnkR8S2x6KB1FPs-J2JUqZeBs7e00g,6733
5
+ CHANGELOG.md,sha256=b1ujyB3oupb7eRJMrfot1E2Ro8JyRtl8nMWKS9WNZVE,7591
6
6
  LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
7
- PKG-INFO,sha256=UkwD-_52GWkQgNpQnMa-cDG4Q_h3sMM1jqGYrM4Kjy8,1325
7
+ PKG-INFO,sha256=__2d0MYZYp69v5s8h-OeHhSCzx5oPTAC2SCbzjaU3Wk,1325
8
8
  README.md,sha256=Od69x-RS85Hph0-WwWACwal4yUd67XkEn4APEfHhHFw,2649
9
- pyproject.toml,sha256=5LVT8PiePyXQ2W_r2fJjtBUzN7BRL233-0tjvBG_b_A,2416
9
+ pyproject.toml,sha256=gMDfspJLGFZ8Bg4B0cJ1YPtCiKazJFCOTBpqCSTSIrw,2416
10
10
  .git_hooks/pre-commit,sha256=n3RofIZHJl8zfJJIUomcMyYGFi_rwq4CC19z0snz3FI,286
11
11
  .gitlab/issue_templates/bug_report_template.md,sha256=gAuyEwl7XlnebBrkiJ9AqffSNOywmr8vygUFWKTuQeI,386
12
12
  .gitlab/issue_templates/documentation_update_template.md,sha256=FHLdb3TS_D9aL4CYZCjyXSulbaW5mrN2CmwTaeLPbNw,860
@@ -61,7 +61,7 @@ bec_widgets/assets/toolbar_icons/transform.svg,sha256=Fgug9wCi1FONy08nssEvnoDDDB
61
61
  bec_widgets/assets/toolbar_icons/waveform.svg,sha256=darXWaIww4HEu9skFUd8Vs1NSAgUo1d37xBNr6DX-bM,231
62
62
  bec_widgets/cli/__init__.py,sha256=d0Q6Fn44e7wFfLabDOBxpcJ1DPKWlFunGYDUBmO-4hA,22
63
63
  bec_widgets/cli/auto_updates.py,sha256=DwzRChcFIWPH2kCYvp8H7dXvyYSKGYv6LwCmK2sDR2E,5676
64
- bec_widgets/cli/client.py,sha256=sqWc80V5RZH3gJdQQnGSDY3LR3ypox8orOkDE1PuI7Q,76650
64
+ bec_widgets/cli/client.py,sha256=e9BWeliuC7__cNTBTWhiKZNK4SD3b8LPptILjNAu7mY,76919
65
65
  bec_widgets/cli/client_utils.py,sha256=l35LtTkD7PdvVCckjMU8-y6f5a5pp1u6cFPpD-Dkvow,11713
66
66
  bec_widgets/cli/generate_cli.py,sha256=Ea5px9KblUlcGg-1JbJBTIU7laGg2n8PM7Efw9WVVzM,5889
67
67
  bec_widgets/cli/rpc_register.py,sha256=QxXUZu5XNg00Yf5O3UHWOXg3-f_pzKjjoZYMOa-MOJc,2216
@@ -85,14 +85,14 @@ bec_widgets/qt_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
85
85
  bec_widgets/qt_utils/error_popups.py,sha256=y9gKKWaafp468ioHr96nBhf02ZpEgjDc-BAVOTWh-e8,7680
86
86
  bec_widgets/qt_utils/redis_message_waiter.py,sha256=fvL_QgC0cTDv_FPJdRyp5AKjf401EJU4z3r38p47ydY,1745
87
87
  bec_widgets/qt_utils/settings_dialog.py,sha256=NhtzTer_xzlB2lLLrGklkI1QYLJEWQpJoZbCz4o5daI,3645
88
- bec_widgets/qt_utils/toolbar.py,sha256=3gmwASDgZiE6SFI9dK3VE-dT4LMqwb68laowF7_rv3o,7773
88
+ bec_widgets/qt_utils/toolbar.py,sha256=YIW0lV1zm7M6dC0mwEmWOYhhmnDfP4d1lMDgd2pwXao,7588
89
89
  bec_widgets/utils/__init__.py,sha256=1930ji1Jj6dVuY81Wd2kYBhHYNV-2R0bN_L4o9zBj1U,533
90
90
  bec_widgets/utils/bec_connector.py,sha256=SivHKXVyNVqeu3kCXYEPpbleTVw8g1cW0FKq1QrQgco,9987
91
91
  bec_widgets/utils/bec_designer.py,sha256=Z3MeMju-KmTz8POtm23VQfp4rvtD2sF6eIOKQkl2F7w,4729
92
92
  bec_widgets/utils/bec_dispatcher.py,sha256=NkObWO_gRO9Uobz-fy0gVTZqQsbFRaKj6fbjYZoErFI,6400
93
93
  bec_widgets/utils/bec_table.py,sha256=nA2b8ukSeUfquFMAxGrUVOqdrzMoDYD6O_4EYbOG2zk,717
94
94
  bec_widgets/utils/bec_widget.py,sha256=Bo2v1aP7rgSAQajW8GBJbI3iovTn_hGCsmeFMo7bT10,707
95
- bec_widgets/utils/colors.py,sha256=hNIi99EpMv3t3hTJIL2jBe5nzh5f2fuCyEKXEPWSQSc,10501
95
+ bec_widgets/utils/colors.py,sha256=2lQZFfmin0YBJVrMH_81wSUPpmFz235_NYHpNRFlrbk,11383
96
96
  bec_widgets/utils/container_utils.py,sha256=0wr3ZfuMiAFKCrQHVjxjw-Vuk8wsHdridqcjy2eY840,1531
97
97
  bec_widgets/utils/crosshair.py,sha256=ywj4Pr2Xx8tFsD5qrHIocanKlNqDd51ElbEfxenuYM0,11363
98
98
  bec_widgets/utils/entry_validator.py,sha256=3skJIsUwTYicT76AMHm_M78RiWtUgyD2zb-Rxo2HdHQ,1313
@@ -133,6 +133,11 @@ bec_widgets/widgets/colormap_selector/colormap_selector.pyproject,sha256=lHl9qml
133
133
  bec_widgets/widgets/colormap_selector/colormap_selector_plugin.py,sha256=3DjuT36quiMOfLwpCzVxRlV6KhkUr6AMjh73HDIGm6w,1371
134
134
  bec_widgets/widgets/colormap_selector/register_colormap_selector.py,sha256=bfw7RWmTmMLTLxGT-izSwcGtxGLKvL3jdivJw2z8oN4,512
135
135
  bec_widgets/widgets/console/console.py,sha256=NG0cBuqqPX4hC-sHhk_UEkT-nHhhN9Y7karJITPLzyo,17864
136
+ bec_widgets/widgets/dark_mode_button/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
137
+ bec_widgets/widgets/dark_mode_button/dark_mode_button.py,sha256=G6Q9pfThp8cWMzCYrKfrZa-26-qBG-SDZFj-ezXRyGc,2319
138
+ bec_widgets/widgets/dark_mode_button/dark_mode_button.pyproject,sha256=Lbi9zb6HNlIq14k6hlzR-oz6PIFShBuF7QxE6d87d64,34
139
+ bec_widgets/widgets/dark_mode_button/dark_mode_button_plugin.py,sha256=rvoXxVkmEa5QKzPIAjZ1_7CLdHmHuCdGHiJGrkIzZz8,1322
140
+ bec_widgets/widgets/dark_mode_button/register_dark_mode_button.py,sha256=_4Fw6j1KLuluko8X2B7zf_DT5eA07G0CqR-aRMAn0iA,489
136
141
  bec_widgets/widgets/device_browser/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
137
142
  bec_widgets/widgets/device_browser/device_browser.py,sha256=PRpgXuAUc6dCWXddp7m_dxUE9VA6AuSzCJ8t3TYng1w,3517
138
143
  bec_widgets/widgets/device_browser/device_browser.pyproject,sha256=s0vM1xYUwyU6Je68_hSCSBLK8ZPfHB-ftt4flfdpkXY,32
@@ -153,12 +158,12 @@ bec_widgets/widgets/device_line_edit/device_line_edit_plugin.py,sha256=4ASFaDcpk
153
158
  bec_widgets/widgets/device_line_edit/register_device_line_edit.py,sha256=8gEPnC8djYCw-idoZAENNB3bPOxM6pbzEp9A366EAGg,489
154
159
  bec_widgets/widgets/dock/__init__.py,sha256=B7foHt02gnhM7mFksa7GJVwT7n0j_JvYDCt6wc6XR5g,61
155
160
  bec_widgets/widgets/dock/dock.py,sha256=hQw5tpGrRbybjfF-aVEAeGdLTudtH4kFa70flu6_ZA8,10349
156
- bec_widgets/widgets/dock/dock_area.py,sha256=VfKyMxKo-r1Ugu2xjSsfGMYZUg3i3xxaokaZCFcCoxA,13579
161
+ bec_widgets/widgets/dock/dock_area.py,sha256=X98q9YZ9gRmA7BOz_GcVKuyH3fsbem-iBH9eUtM5Pi4,14416
157
162
  bec_widgets/widgets/dock/dock_area.pyproject,sha256=URW0UrDXCnkzk80rbQmUMgF6Uqay2TjHsq8Dq0g1j-c,37
158
163
  bec_widgets/widgets/dock/dock_area_plugin.py,sha256=BqWvXzRm90kZGKgP26APt7f6ARBWzLU839vGAjl7UYM,1308
159
164
  bec_widgets/widgets/dock/register_dock_area.py,sha256=Yqd1mq6CcHwlxHZxX5EHKONy4P44nMm8pso-4X0tvJI,464
160
165
  bec_widgets/widgets/figure/__init__.py,sha256=3hGx_KOV7QHCYAV06aNuUgKq4QIYCjUTad-DrwkUaBM,44
161
- bec_widgets/widgets/figure/figure.py,sha256=yujtlDj5NutRJ0gfHMkCVXvBNj5r2z3pb3gwWlUQ92Q,28822
166
+ bec_widgets/widgets/figure/figure.py,sha256=ArJ_fN6xvqzuK8p6YQJfMJwSTh-Rvk69TKIgItPmBeA,28777
162
167
  bec_widgets/widgets/figure/plots/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
163
168
  bec_widgets/widgets/figure/plots/axis_settings.py,sha256=QxRpQwgfBr1H0HTjfOpiXi_-n8I0BaZhS8LRXNeVfFg,3544
164
169
  bec_widgets/widgets/figure/plots/axis_settings.ui,sha256=a2qIuK9lyi9HCyrSvPr6wxzmm1FymaWcpmyOhMIiFt8,11013
@@ -175,14 +180,14 @@ bec_widgets/widgets/figure/plots/waveform/waveform_curve.py,sha256=ZwRxSfPHbMWEv
175
180
  bec_widgets/widgets/image/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
176
181
  bec_widgets/widgets/image/bec_image_widget.pyproject,sha256=PHisdBo5_5UCApd27GkizzqgfdjsDx2bFZa_p9LiSW8,30
177
182
  bec_widgets/widgets/image/bec_image_widget_plugin.py,sha256=vU9JnJwz0TTITH4fK6uVGmbTnPdV8kLu2BIJU_LQH4c,1352
178
- bec_widgets/widgets/image/image_widget.py,sha256=TCpTF8v94iSMklG9bYxZOjm9SbO60XZB9X0ldEp8lWE,16288
183
+ bec_widgets/widgets/image/image_widget.py,sha256=6KtyMAr_iCA8TmzKkM4CogJLkr9BepfceWtEdMeEjlg,16325
179
184
  bec_widgets/widgets/image/register_bec_image_widget.py,sha256=01YLZQTMSSIXvH1TSL-1AYsRs1a4EbSwKLVAwh9AjeA,478
180
185
  bec_widgets/widgets/jupyter_console/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
181
186
  bec_widgets/widgets/jupyter_console/jupyter_console.py,sha256=-e7HQOECeH5eDrJYh4BFIzRL78LDkooU4otabyN0aX4,2343
182
187
  bec_widgets/widgets/motor_map/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
183
188
  bec_widgets/widgets/motor_map/bec_motor_map_widget.pyproject,sha256=NAI8s5gRKz80ED4KY7OgD2OgSH5HEsjt2ux2BYp66yg,63
184
189
  bec_widgets/widgets/motor_map/bec_motor_map_widget_plugin.py,sha256=NSUlP06rTB73GKik7KR_sO66Yu-gp5_XA7ApgTbcwJo,1283
185
- bec_widgets/widgets/motor_map/motor_map_widget.py,sha256=URcysThbJKGsCZUqQm2lCtVn5FG8t4kT7DaN5EJUexg,7555
190
+ bec_widgets/widgets/motor_map/motor_map_widget.py,sha256=vA1XuxMN5uBzvgdkogUnChtRXqMyIfcGXV9xdJMmgA0,7607
186
191
  bec_widgets/widgets/motor_map/register_bec_motor_map_widget.py,sha256=qRG8PtWGjso0pWbvj_DXKnbUfmQzfGqPSrnAozXfM7o,492
187
192
  bec_widgets/widgets/motor_map/motor_map_dialog/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
188
193
  bec_widgets/widgets/motor_map/motor_map_dialog/motor_map_settings.py,sha256=U-r3YHsxf2XvZn0kVbrYIT2aXKSaG5wM1JEnGzwGMVU,2258
@@ -193,7 +198,7 @@ bec_widgets/widgets/position_indicator/position_indicator.pyproject,sha256=s0JEf
193
198
  bec_widgets/widgets/position_indicator/position_indicator_plugin.py,sha256=5efV6Y5LSvCHgg2wogAs7JfKfDhzv59NFT0uT17cWsk,1409
194
199
  bec_widgets/widgets/position_indicator/register_position_indicator.py,sha256=OZNiMgM_80TPSAXK_0hXAkne4vUh8DGvh_OdpOiMpwI,516
195
200
  bec_widgets/widgets/positioner_box/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
196
- bec_widgets/widgets/positioner_box/positioner_box.py,sha256=FyUGskWAb-5m44bdUNVig_AkoDbLRbB0GucI6RRHge8,10839
201
+ bec_widgets/widgets/positioner_box/positioner_box.py,sha256=dIShqGXPpltgNzzb6AzXCtWugk3xWsiYBoBwgcLaA3Y,10774
197
202
  bec_widgets/widgets/positioner_box/positioner_box.pyproject,sha256=7966pHdDseaHciaPNEKgdQgbUThSZf5wEDCeAEJh9po,32
198
203
  bec_widgets/widgets/positioner_box/positioner_box.ui,sha256=Y-Xp0z32okT7X4-rL5r7dF_QH_QpXvPes3f778cC7_k,5633
199
204
  bec_widgets/widgets/positioner_box/positioner_box_plugin.py,sha256=pcZcE0lwgdyWsopwi5ZM1tw32P5uD5QOtEC7sLYQIEc,1404
@@ -211,7 +216,7 @@ bec_widgets/widgets/ring_progress_bar/ring_progress_bar.pyproject,sha256=ZNYDnKD
211
216
  bec_widgets/widgets/ring_progress_bar/ring_progress_bar_plugin.py,sha256=4wYVyxs8osUa1VuJUI5A2KdCCghmZXwsNCEtFQq6pYI,1384
212
217
  bec_widgets/widgets/scan_control/__init__.py,sha256=IOfHl15vxb_uC6KN62-PeUzbBha_vQyqkkXbJ2HU674,38
213
218
  bec_widgets/widgets/scan_control/register_scan_control.py,sha256=xUX2yR0-MaIMg9_y9qe50yDDphzsh2x1b5PMrF90yPM,475
214
- bec_widgets/widgets/scan_control/scan_control.py,sha256=30pcaVaBVo6JxJuMH1ul1s-sPuWqCUKsUQ-XfAgzRZ8,9384
219
+ bec_widgets/widgets/scan_control/scan_control.py,sha256=9cvFMZbU5ttoXpJAjcKVU3MnsUwc2XN3x9qlGEIL0IY,9434
215
220
  bec_widgets/widgets/scan_control/scan_control.pyproject,sha256=eTgVDFKToIH8_BbJjM2RvbOLr7HnYoidX0SAHx640DM,30
216
221
  bec_widgets/widgets/scan_control/scan_control_plugin.py,sha256=Oe0jvKoLa1jvV7IyoExTzd2vvJbKPgUUt4_cdunsVNY,1350
217
222
  bec_widgets/widgets/scan_control/scan_group_box.py,sha256=BpX9ZphqOhdEbQnGzNeNlmuZsMS__U97CkBMical2FY,9300
@@ -232,7 +237,7 @@ bec_widgets/widgets/text_box/text_box.pyproject,sha256=XohO1BIe2hrpU-z_KHKRgjcUk
232
237
  bec_widgets/widgets/text_box/text_box_plugin.py,sha256=UAbDbSgI3s2FniFSrNFe_VVTc3VzEphOS3lI9mRPwmY,1291
233
238
  bec_widgets/widgets/toggle/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
234
239
  bec_widgets/widgets/toggle/register_toggle_switch.py,sha256=8pVtkeEeiDOjV4OPoZq1I30F9JDzl4nQE7e7xoWyWBs,472
235
- bec_widgets/widgets/toggle/toggle.py,sha256=JzCGYoyHBrlBWCoyL94QX4zSLyEwWbCNHMegjlnSy2E,4442
240
+ bec_widgets/widgets/toggle/toggle.py,sha256=xW5WAtjzzRgTpHsyoRSTVoiaKcX8vxsbbDd_J46EJYM,4451
236
241
  bec_widgets/widgets/toggle/toggle_switch.pyproject,sha256=Msa-AS5H5XlqW65r8GlX2AxD8FnFnDyDgGnbKcXqKOw,24
237
242
  bec_widgets/widgets/toggle/toggle_switch_plugin.py,sha256=NSrk8KkolyOOxkliTwqz2n_l7jNPTjSFfcc9iCuzkiU,1333
238
243
  bec_widgets/widgets/vscode/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -244,10 +249,10 @@ bec_widgets/widgets/waveform/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
244
249
  bec_widgets/widgets/waveform/bec_waveform_widget.pyproject,sha256=GLD8GN9dXx9wNbtnevrxqqcwk7vKV-Uv8QYSycdaoaI,33
245
250
  bec_widgets/widgets/waveform/bec_waveform_widget_plugin.py,sha256=Qt8E5nvk6f5JYwOqVn5UkbIW_JqsXkIMdv3CM41gXsU,1387
246
251
  bec_widgets/widgets/waveform/register_bec_waveform_widget.py,sha256=qZHVZH_lP2hvzkG1Ra0EyrXlMeLkRCy0aceH-bfJ1cs,490
247
- bec_widgets/widgets/waveform/waveform_widget.py,sha256=nzRDgo_qfmmp_aSGbXhwy2U7yq5cR0pHdjM0YDCvTKE,20409
252
+ bec_widgets/widgets/waveform/waveform_widget.py,sha256=7oOLIIQbx1Oam89cjtAidRU1QFLphTk-ALSRbiessrY,20512
248
253
  bec_widgets/widgets/waveform/waveform_popups/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
249
254
  bec_widgets/widgets/waveform/waveform_popups/curve_dialog/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
250
- bec_widgets/widgets/waveform/waveform_popups/curve_dialog/curve_dialog.py,sha256=S1j44i1xxJtmCcNtbOsxF8XdklMPsG9t4-1DZ2YfOPw,13128
255
+ bec_widgets/widgets/waveform/waveform_popups/curve_dialog/curve_dialog.py,sha256=5e2BrKA97cfZCM04x7-S3z6sby82KKnUH1S0gVQUfLU,13090
251
256
  bec_widgets/widgets/waveform/waveform_popups/curve_dialog/curve_dialog.ui,sha256=OaQE5HlyBQ3RQoHqxOFHiUoNcx8SDZP5sHJ9NNGhsPI,10404
252
257
  bec_widgets/widgets/waveform/waveform_popups/dap_summary_dialog/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
253
258
  bec_widgets/widgets/waveform/waveform_popups/dap_summary_dialog/dap_summary.ui,sha256=PFEKro61UXd-jmx65U4pqJ5D29DXtVnhQRnsnDvN-wM,6138
@@ -315,7 +320,9 @@ docs/user/widgets/bec_figure/BECFigure.png,sha256=8dQr4u0uk_y0VV-R1Jh9yTR3Vidd9H
315
320
  docs/user/widgets/bec_figure/bec_figure.md,sha256=_HDsRXf45N8NDwfHt4HqI3uDMr5Tx_A6RB7yY9m1l8c,6023
316
321
  docs/user/widgets/bec_status_box/bec_status_box.gif,sha256=kLxf40HbS6fjdUIQ2b9SiduBEXdBd4DDWGEnQDOFMcY,1259044
317
322
  docs/user/widgets/bec_status_box/bec_status_box.md,sha256=e23y7DYg63IwFFInDozDslh9BdYvbWY3NGiwv6_Fc3Q,2056
318
- docs/user/widgets/buttons/buttons.md,sha256=WVeRcOPCk9a28lbJ-25Eqd7U6uNL_YXYGl4WddOUwkc,1974
323
+ docs/user/widgets/buttons/buttons.md,sha256=1VgkVl2o5ERKjuPJFOZtxvpY-wDLR7P19-lJzQwBFQM,2677
324
+ docs/user/widgets/buttons/dark_mode_disabled.png,sha256=eSLZLGcKCS3uQ4NDhJaUYr9gL56CnPblJvRvEPG6h-g,5156
325
+ docs/user/widgets/buttons/dark_mode_enabled.png,sha256=hf4u_AeR4Gri1F87_7lcRt7Q3QnJ42f5g2vN7QkfFGA,4121
319
326
  docs/user/widgets/device_browser/device_browser.md,sha256=kzZrS3aoWbmUUPygjGNuXJ7_qqD35WJN-HwQHx5hpmI,1102
320
327
  docs/user/widgets/device_browser/device_browser.png,sha256=85clca-gpCyxTL-SOS8hmgDmjbZ5i-0ZmOVA6vBZBUA,46429
321
328
  docs/user/widgets/device_input/device_input.md,sha256=5zkBeCX_I8TBM0rHi2WHgqrM0k64VoC87vhIWyo3Isc,3878
@@ -368,6 +375,7 @@ tests/unit_tests/test_client_utils.py,sha256=CBdWIVJ_UiyFzTJnX3XJm4PGw2uXhFvRCP_
368
375
  tests/unit_tests/test_color_map_selector.py,sha256=dTsizpT7TUpX2AEWIc0v09KPOryhWepFXFI9duQ3NF8,1497
369
376
  tests/unit_tests/test_color_validation.py,sha256=xbFbtFDia36XLgaNrX2IwvAX3IDC_Odpj5BGoJSgiIE,2389
370
377
  tests/unit_tests/test_crosshair.py,sha256=POB9EFCO9gCCAEHgddiyQV28C4rMxIosHX0aR-zr8gg,4595
378
+ tests/unit_tests/test_dark_mode_button.py,sha256=GcfdRZuk7iovw1-EYIG6bTBf2B13eFdzPvzYV5bA__c,2226
371
379
  tests/unit_tests/test_device_browser.py,sha256=LOvvUFepNcoQptX7d6oUoomfg5nyjjdCMJ2iHviF9aQ,2948
372
380
  tests/unit_tests/test_device_input_base.py,sha256=LY-3adMb2xM9pBiP6V2bAJF_65csCe2Xfaq5ArVEE1E,2859
373
381
  tests/unit_tests/test_device_input_widgets.py,sha256=Y3mc_EaeQAPxpj6DijvxLLyMPSxnaNN86KhIL4ASO3E,5821
@@ -400,8 +408,8 @@ tests/unit_tests/test_configs/config_device_no_entry.yaml,sha256=hdvue9KLc_kfNzG
400
408
  tests/unit_tests/test_configs/config_scan.yaml,sha256=vo484BbWOjA_e-h6bTjSV9k7QaQHrlAvx-z8wtY-P4E,1915
401
409
  tests/unit_tests/test_msgs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
402
410
  tests/unit_tests/test_msgs/available_scans_message.py,sha256=m_z97hIrjHXXMa2Ex-UvsPmTxOYXfjxyJaGkIY6StTY,46532
403
- bec_widgets-0.97.0.dist-info/METADATA,sha256=UkwD-_52GWkQgNpQnMa-cDG4Q_h3sMM1jqGYrM4Kjy8,1325
404
- bec_widgets-0.97.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
405
- bec_widgets-0.97.0.dist-info/entry_points.txt,sha256=3otEkCdDB9LZJuBLzG4pFLK5Di0CVybN_12IsZrQ-58,166
406
- bec_widgets-0.97.0.dist-info/licenses/LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
407
- bec_widgets-0.97.0.dist-info/RECORD,,
411
+ bec_widgets-0.99.0.dist-info/METADATA,sha256=__2d0MYZYp69v5s8h-OeHhSCzx5oPTAC2SCbzjaU3Wk,1325
412
+ bec_widgets-0.99.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
413
+ bec_widgets-0.99.0.dist-info/entry_points.txt,sha256=3otEkCdDB9LZJuBLzG4pFLK5Di0CVybN_12IsZrQ-58,166
414
+ bec_widgets-0.99.0.dist-info/licenses/LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
415
+ bec_widgets-0.99.0.dist-info/RECORD,,
@@ -14,6 +14,18 @@ The `Stop Button` is a specialized control that provides an immediate interface
14
14
  - **Immediate Termination**: Instantly halts the execution of the current script or process.
15
15
  - **Queue Management**: Clears any pending operations in the scan queue, ensuring the system is reset and ready for new tasks.
16
16
 
17
+ ## Dark Mode Button
18
+
19
+ The `Dark Mode Button` is a toggle control that allows users to switch between light and dark themes in the BEC GUI. It provides a convenient way to adjust the interface's appearance based on user preferences or environmental conditions.
20
+
21
+ ```{figure} ./dark_mode_enabled.png
22
+ ```
23
+ ```{figure} ./dark_mode_disabled.png
24
+ ```
25
+
26
+ **Key Features:**
27
+ - **Theme Switching**: Enables users to switch between light and dark themes with a single click.
28
+ - **Configurable from BECDesigner**: The defaults for the dark mode can be set in the BECDesigner, allowing users to customize the startup appearance of the GUI.
17
29
  ````
18
30
 
19
31
  ````{tab} Examples
@@ -46,5 +58,6 @@ my_gui.show()
46
58
  ````{tab} API
47
59
  ```{eval-rst}
48
60
  .. include:: /api_reference/_autosummary/bec_widgets.cli.client.StopButton.rst
61
+ .. include:: /api_reference/_autosummary/bec_widgets.cli.client.DarkModeButton.rst
49
62
  ```
50
63
  ````
pyproject.toml CHANGED
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "bec_widgets"
7
- version = "0.97.0"
7
+ version = "0.99.0"
8
8
  description = "BEC Widgets"
9
9
  requires-python = ">=3.10"
10
10
  classifiers = [
@@ -0,0 +1,70 @@
1
+ from unittest import mock
2
+
3
+ import pytest
4
+ from qtpy.QtCore import Qt
5
+
6
+ from bec_widgets.widgets.dark_mode_button.dark_mode_button import DarkModeButton
7
+
8
+ # pylint: disable=unused-import
9
+ from .client_mocks import mocked_client
10
+
11
+ # pylint: disable=redefined-outer-name
12
+
13
+
14
+ @pytest.fixture
15
+ def dark_mode_button(qtbot, mocked_client):
16
+ """
17
+ Fixture for the dark mode button.
18
+ """
19
+ button = DarkModeButton(client=mocked_client)
20
+ qtbot.addWidget(button)
21
+ qtbot.waitExposed(button)
22
+ yield button
23
+
24
+
25
+ def test_dark_mode_button_init(dark_mode_button):
26
+ """
27
+ Test that the dark mode button is initialized correctly.
28
+ """
29
+ assert dark_mode_button.dark_mode_enabled is False
30
+ assert dark_mode_button.mode_button.toolTip() == "Set Dark Mode"
31
+
32
+
33
+ def test_dark_mode_button_toggle(dark_mode_button):
34
+ """
35
+ Test that the dark mode button toggles correctly.
36
+ """
37
+ dark_mode_button.toggle_dark_mode()
38
+ assert dark_mode_button.dark_mode_enabled is True
39
+ assert dark_mode_button.mode_button.toolTip() == "Set Light Mode"
40
+
41
+ dark_mode_button.toggle_dark_mode()
42
+ assert dark_mode_button.dark_mode_enabled == False
43
+ assert dark_mode_button.mode_button.toolTip() == "Set Dark Mode"
44
+
45
+
46
+ def test_dark_mode_button_toggles_on_click(dark_mode_button, qtbot):
47
+ """
48
+ Test that the dark mode button toggles correctly when clicked.
49
+ """
50
+ qtbot.mouseClick(dark_mode_button.mode_button, Qt.MouseButton.LeftButton)
51
+ assert dark_mode_button.dark_mode_enabled is True
52
+ assert dark_mode_button.mode_button.toolTip() == "Set Light Mode"
53
+
54
+ qtbot.mouseClick(dark_mode_button.mode_button, Qt.MouseButton.LeftButton)
55
+ assert dark_mode_button.dark_mode_enabled is False
56
+ assert dark_mode_button.mode_button.toolTip() == "Set Dark Mode"
57
+
58
+
59
+ def test_dark_mode_button_changes_theme(dark_mode_button):
60
+ """
61
+ Test that the dark mode button changes the theme correctly.
62
+ """
63
+ with mock.patch(
64
+ "bec_widgets.widgets.dark_mode_button.dark_mode_button.set_theme"
65
+ ) as mocked_set_theme:
66
+ dark_mode_button.toggle_dark_mode()
67
+ mocked_set_theme.assert_called_with("dark")
68
+
69
+ dark_mode_button.toggle_dark_mode()
70
+ mocked_set_theme.assert_called_with("light")