bec-widgets 0.98.0__py3-none-any.whl → 0.99.1__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.
CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v0.99.1 (2024-08-27)
4
+
5
+ ### Fix
6
+
7
+ * fix(crosshair): emit all crosshair events, not just line coordinates ([`2265458`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/2265458dcc57970db18c62619f5877d542d72e81))
8
+
9
+ ## v0.99.0 (2024-08-25)
10
+
11
+ ### Documentation
12
+
13
+ * docs(darkmodebutton): added dark mode button docs ([`406c263`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/406c263746f0e809c1a4d98356c48f40428c23d7))
14
+
15
+ ### Feature
16
+
17
+ * feat(darkmodebutton): added button to toggle between dark and light mode ([`cc8c166`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/cc8c166b5c1d37e0f64c83801b2347a54a6550b6))
18
+
19
+ ### Fix
20
+
21
+ * fix(toggle): emit state change ([`c4f3308`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/c4f3308dc0c3e4b2064760ccd7372d71b3e49f96))
22
+
23
+ ### Refactor
24
+
25
+ * refactor(darkmodebutton): renamed set_dark_mode_enabled to toggle_dark_mode ([`c70724a`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/c70724a456900bcb06b040407a2c5d497e49ce77))
26
+
27
+ ### Test
28
+
29
+ * test(dark_mode_button): added tests for dark mode button ([`df35aab`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/df35aabff30c5d00b1c441132bd370446653741e))
30
+
3
31
  ## v0.98.0 (2024-08-25)
4
32
 
5
33
  ### Feature
@@ -125,29 +153,3 @@
125
153
  ### Test
126
154
 
127
155
  * test: added test for device browser ([`e870e5b`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/e870e5ba083c61df581c9c0305adabe72967f997))
128
-
129
- ## v0.94.7 (2024-08-20)
130
-
131
- ### Fix
132
-
133
- * fix: formatting of stdout, stderr captured text for logger ([`939f834`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/939f834a26ddbac0bdead0b60b1cdf52014f182f))
134
-
135
- ## v0.94.6 (2024-08-14)
136
-
137
- ### Fix
138
-
139
- * fix(server): emit heartbeat with state ([`bc2abe9`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/bc2abe945fb5adeec89ed5ac45e966db86ce6ffc))
140
-
141
- ## v0.94.5 (2024-08-14)
142
-
143
- ### Build
144
-
145
- * build: increased min version of bec to 2.21.4
146
-
147
- Since we now rely on reusing the BECClient singleton, we need the fix introduced with 2.21.4 in BEC. ([`4f96d0e`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/4f96d0e4a14edc4b2839c1dddeda384737dc7a8a))
148
-
149
- ### Fix
150
-
151
- * fix(rpc): use client singleton instead of dispatcher ([`ea9240d`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/ea9240d2f71931082f33fb6b68231469875c3d63))
152
-
153
- * fix: removed qcoreapplication for polling events ([`4d02b42`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/4d02b42f11e9882b843317255a4975565c8a536f))
PKG-INFO CHANGED
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: bec_widgets
3
- Version: 0.98.0
3
+ Version: 0.99.1
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
@@ -9,6 +9,8 @@ from qtpy.QtCore import Signal as pyqtSignal
9
9
 
10
10
 
11
11
  class Crosshair(QObject):
12
+ positionChanged = pyqtSignal(tuple)
13
+ positionClicked = pyqtSignal(tuple)
12
14
  # Signal for 1D plot
13
15
  coordinatesChanged1D = pyqtSignal(tuple)
14
16
  coordinatesClicked1D = pyqtSignal(tuple)
@@ -164,6 +166,7 @@ class Crosshair(QObject):
164
166
  """
165
167
  pos = event[0]
166
168
  self.update_markers()
169
+ self.positionChanged.emit((pos.x(), pos.y()))
167
170
  if self.plot_item.vb.sceneBoundingRect().contains(pos):
168
171
  mouse_point = self.plot_item.vb.mapSceneToView(pos)
169
172
  self.v_line.setPos(mouse_point.x())
@@ -217,6 +220,7 @@ class Crosshair(QObject):
217
220
  if self.plot_item.vb.sceneBoundingRect().contains(event._scenePos):
218
221
  mouse_point = self.plot_item.vb.mapSceneToView(event._scenePos)
219
222
  x, y = mouse_point.x(), mouse_point.y()
223
+ self.positionClicked.emit((x, y))
220
224
 
221
225
  if self.is_log_x:
222
226
  x = 10**x
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()
@@ -56,6 +56,8 @@ class BECViewBox(pg.ViewBox):
56
56
 
57
57
 
58
58
  class BECPlotBase(BECConnector, pg.GraphicsLayout):
59
+ crosshair_position_changed = Signal(tuple)
60
+ crosshair_position_clicked = Signal(tuple)
59
61
  crosshair_coordinates_changed = Signal(tuple)
60
62
  crosshair_coordinates_clicked = Signal(tuple)
61
63
  USER_ACCESS = [
@@ -328,6 +330,8 @@ class BECPlotBase(BECConnector, pg.GraphicsLayout):
328
330
  """Hook the crosshair to all plots."""
329
331
  if self.crosshair is None:
330
332
  self.crosshair = Crosshair(self.plot_item, precision=3)
333
+ self.crosshair.positionChanged.connect(self.crosshair_position_changed)
334
+ self.crosshair.positionClicked.connect(self.crosshair_position_clicked)
331
335
  self.crosshair.coordinatesChanged1D.connect(self.crosshair_coordinates_changed)
332
336
  self.crosshair.coordinatesClicked1D.connect(self.crosshair_coordinates_clicked)
333
337
  self.crosshair.coordinatesChanged2D.connect(self.crosshair_coordinates_changed)
@@ -336,6 +340,8 @@ class BECPlotBase(BECConnector, pg.GraphicsLayout):
336
340
  def unhook_crosshair(self) -> None:
337
341
  """Unhook the crosshair from all plots."""
338
342
  if self.crosshair is not None:
343
+ self.crosshair.positionChanged.disconnect(self.crosshair_position_changed)
344
+ self.crosshair.positionClicked.disconnect(self.crosshair_position_clicked)
339
345
  self.crosshair.coordinatesChanged1D.disconnect(self.crosshair_coordinates_changed)
340
346
  self.crosshair.coordinatesClicked1D.disconnect(self.crosshair_coordinates_clicked)
341
347
  self.crosshair.coordinatesChanged2D.disconnect(self.crosshair_coordinates_changed)
@@ -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
 
@@ -58,8 +58,14 @@ class BECWaveformWidget(BECWidget, QWidget):
58
58
  dap_summary_update = Signal(dict)
59
59
  autorange_signal = Signal()
60
60
  new_scan = Signal()
61
+ crosshair_position_changed = Signal(tuple)
62
+ crosshair_position_changed_string = Signal(str)
63
+ crosshair_position_clicked = Signal(tuple)
64
+ crosshair_position_clicked_string = Signal(str)
61
65
  crosshair_coordinates_changed = Signal(tuple)
66
+ crosshair_coordinates_changed_string = Signal(str)
62
67
  crosshair_coordinates_clicked = Signal(tuple)
68
+ crosshair_coordinates_clicked_string = Signal(str)
63
69
 
64
70
  def __init__(
65
71
  self,
@@ -136,6 +142,20 @@ class BECWaveformWidget(BECWidget, QWidget):
136
142
  self.waveform.new_scan.connect(self.new_scan)
137
143
  self.waveform.crosshair_coordinates_changed.connect(self.crosshair_coordinates_changed)
138
144
  self.waveform.crosshair_coordinates_clicked.connect(self.crosshair_coordinates_clicked)
145
+ self.waveform.crosshair_coordinates_changed.connect(
146
+ self._emit_crosshair_coordinates_changed_string
147
+ )
148
+ self.waveform.crosshair_coordinates_clicked.connect(
149
+ self._emit_crosshair_coordinates_clicked_string
150
+ )
151
+ self.waveform.crosshair_position_changed.connect(self.crosshair_position_changed)
152
+ self.waveform.crosshair_position_clicked.connect(self.crosshair_position_clicked)
153
+ self.waveform.crosshair_position_changed.connect(
154
+ self._emit_crosshair_position_changed_string
155
+ )
156
+ self.waveform.crosshair_position_clicked.connect(
157
+ self._emit_crosshair_position_clicked_string
158
+ )
139
159
 
140
160
  def _hook_actions(self):
141
161
  self.toolbar.widgets["save"].action.triggered.connect(self.export)
@@ -156,6 +176,22 @@ class BECWaveformWidget(BECWidget, QWidget):
156
176
  # lambda: self.save_config(path=None, gui=True)
157
177
  # )
158
178
 
179
+ @SafeSlot(tuple)
180
+ def _emit_crosshair_coordinates_changed_string(self, coordinates):
181
+ self.crosshair_coordinates_changed_string.emit(str(coordinates))
182
+
183
+ @SafeSlot(tuple)
184
+ def _emit_crosshair_coordinates_clicked_string(self, coordinates):
185
+ self.crosshair_coordinates_clicked_string.emit(str(coordinates))
186
+
187
+ @SafeSlot(tuple)
188
+ def _emit_crosshair_position_changed_string(self, position):
189
+ self.crosshair_position_changed_string.emit(str(position))
190
+
191
+ @SafeSlot(tuple)
192
+ def _emit_crosshair_position_clicked_string(self, position):
193
+ self.crosshair_position_clicked_string.emit(str(position))
194
+
159
195
  ###################################
160
196
  # Dialog Windows
161
197
  ###################################
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: bec_widgets
3
- Version: 0.98.0
3
+ Version: 0.99.1
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=gjQfqaLDuPUnF3DFFQqOFpYcJNBi7cVD6D_-knI9F2k,6839
5
+ CHANGELOG.md,sha256=TrmYDiypc90eYaa-faQzSvVKyS3bZt1pBLSqIpUqDeU,6964
6
6
  LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
7
- PKG-INFO,sha256=IAkC6nhPjMKZoERtnUZtDsEU4stXZjICC1FDwQuyuoM,1325
7
+ PKG-INFO,sha256=MVPi_Ok7cGpSqZHITDtcZCuEBiWaMs7LXnzOk1olL-o,1325
8
8
  README.md,sha256=Od69x-RS85Hph0-WwWACwal4yUd67XkEn4APEfHhHFw,2649
9
- pyproject.toml,sha256=61TgaqglyIMXu3W2TMVVhZwG5g2bN4ShiDCSw16LnTE,2416
9
+ pyproject.toml,sha256=yN4Aw4TTp4pjQtn1s3UdvUKePIwRCP8wfcqGakRG7Rs,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
@@ -94,7 +94,7 @@ bec_widgets/utils/bec_table.py,sha256=nA2b8ukSeUfquFMAxGrUVOqdrzMoDYD6O_4EYbOG2z
94
94
  bec_widgets/utils/bec_widget.py,sha256=Bo2v1aP7rgSAQajW8GBJbI3iovTn_hGCsmeFMo7bT10,707
95
95
  bec_widgets/utils/colors.py,sha256=2lQZFfmin0YBJVrMH_81wSUPpmFz235_NYHpNRFlrbk,11383
96
96
  bec_widgets/utils/container_utils.py,sha256=0wr3ZfuMiAFKCrQHVjxjw-Vuk8wsHdridqcjy2eY840,1531
97
- bec_widgets/utils/crosshair.py,sha256=ywj4Pr2Xx8tFsD5qrHIocanKlNqDd51ElbEfxenuYM0,11363
97
+ bec_widgets/utils/crosshair.py,sha256=8lik9k69WI2WMj5FGLbrKtny9duxqXUJAhpX8tHoyp0,11543
98
98
  bec_widgets/utils/entry_validator.py,sha256=3skJIsUwTYicT76AMHm_M78RiWtUgyD2zb-Rxo2HdHQ,1313
99
99
  bec_widgets/utils/generate_designer_plugin.py,sha256=eidqauS8YLgoxkPntPL0oSG_lYqI2D7fSyOZvOtCU_U,5891
100
100
  bec_widgets/utils/layout_manager.py,sha256=H0nKsIMaPxRkof1MEXlSmW6w1dFxA6astaGzf4stI84,4727
@@ -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
@@ -162,7 +167,7 @@ bec_widgets/widgets/figure/figure.py,sha256=ArJ_fN6xvqzuK8p6YQJfMJwSTh-Rvk69TKIg
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
165
- bec_widgets/widgets/figure/plots/plot_base.py,sha256=30KsfR6SlbeuV_t96kILcPU17vf_qMHajlvFwfBvN2Y,13593
170
+ bec_widgets/widgets/figure/plots/plot_base.py,sha256=RLQeize3X02rzp5DyBzvQI7SdA4DiEuFH-Dzij1mohg,14029
166
171
  bec_widgets/widgets/figure/plots/image/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
167
172
  bec_widgets/widgets/figure/plots/image/image.py,sha256=y2MqgJv6Njv-huDN_exn0Fq1rAh5vs_assKCKHgQH6I,24941
168
173
  bec_widgets/widgets/figure/plots/image/image_item.py,sha256=RljjbkqJEr2cKDlqj1j5GQ1h89jpqOV-OpFz1TbED8I,10937
@@ -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,7 +249,7 @@ 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=7oOLIIQbx1Oam89cjtAidRU1QFLphTk-ALSRbiessrY,20512
252
+ bec_widgets/widgets/waveform/waveform_widget.py,sha256=LD5nx6Z2wxiaMK7ukrFzwJDojrkj3pn_oG2eZqguulE,22152
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
255
  bec_widgets/widgets/waveform/waveform_popups/curve_dialog/curve_dialog.py,sha256=5e2BrKA97cfZCM04x7-S3z6sby82KKnUH1S0gVQUfLU,13090
@@ -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.98.0.dist-info/METADATA,sha256=IAkC6nhPjMKZoERtnUZtDsEU4stXZjICC1FDwQuyuoM,1325
404
- bec_widgets-0.98.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
405
- bec_widgets-0.98.0.dist-info/entry_points.txt,sha256=3otEkCdDB9LZJuBLzG4pFLK5Di0CVybN_12IsZrQ-58,166
406
- bec_widgets-0.98.0.dist-info/licenses/LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
407
- bec_widgets-0.98.0.dist-info/RECORD,,
411
+ bec_widgets-0.99.1.dist-info/METADATA,sha256=MVPi_Ok7cGpSqZHITDtcZCuEBiWaMs7LXnzOk1olL-o,1325
412
+ bec_widgets-0.99.1.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
413
+ bec_widgets-0.99.1.dist-info/entry_points.txt,sha256=3otEkCdDB9LZJuBLzG4pFLK5Di0CVybN_12IsZrQ-58,166
414
+ bec_widgets-0.99.1.dist-info/licenses/LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
415
+ bec_widgets-0.99.1.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.98.0"
7
+ version = "0.99.1"
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")