bec-widgets 0.98.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.
- CHANGELOG.md +22 -2
- PKG-INFO +1 -1
- bec_widgets/cli/client.py +10 -0
- bec_widgets/widgets/dark_mode_button/__init__.py +0 -0
- bec_widgets/widgets/dark_mode_button/dark_mode_button.py +71 -0
- bec_widgets/widgets/dark_mode_button/dark_mode_button.pyproject +1 -0
- bec_widgets/widgets/dark_mode_button/dark_mode_button_plugin.py +54 -0
- bec_widgets/widgets/dark_mode_button/register_dark_mode_button.py +15 -0
- bec_widgets/widgets/toggle/toggle.py +5 -4
- {bec_widgets-0.98.0.dist-info → bec_widgets-0.99.0.dist-info}/METADATA +1 -1
- {bec_widgets-0.98.0.dist-info → bec_widgets-0.99.0.dist-info}/RECORD +19 -11
- docs/user/widgets/buttons/buttons.md +13 -0
- docs/user/widgets/buttons/dark_mode_disabled.png +0 -0
- docs/user/widgets/buttons/dark_mode_enabled.png +0 -0
- pyproject.toml +1 -1
- tests/unit_tests/test_dark_mode_button.py +70 -0
- {bec_widgets-0.98.0.dist-info → bec_widgets-0.99.0.dist-info}/WHEEL +0 -0
- {bec_widgets-0.98.0.dist-info → bec_widgets-0.99.0.dist-info}/entry_points.txt +0 -0
- {bec_widgets-0.98.0.dist-info → bec_widgets-0.99.0.dist-info}/licenses/LICENSE +0 -0
CHANGELOG.md
CHANGED
@@ -1,5 +1,27 @@
|
|
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
|
+
|
3
25
|
## v0.98.0 (2024-08-25)
|
4
26
|
|
5
27
|
### Feature
|
@@ -149,5 +171,3 @@ Since we now rely on reusing the BECClient singleton, we need the fix introduced
|
|
149
171
|
### Fix
|
150
172
|
|
151
173
|
* 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
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
|
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()
|
@@ -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.
|
113
|
-
self.update_colors()
|
114
|
-
self.animate_thumb()
|
115
|
+
self.checked = not self.checked
|
115
116
|
|
116
117
|
def update_colors(self):
|
117
118
|
|
@@ -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=
|
5
|
+
CHANGELOG.md,sha256=b1ujyB3oupb7eRJMrfot1E2Ro8JyRtl8nMWKS9WNZVE,7591
|
6
6
|
LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
|
7
|
-
PKG-INFO,sha256=
|
7
|
+
PKG-INFO,sha256=__2d0MYZYp69v5s8h-OeHhSCzx5oPTAC2SCbzjaU3Wk,1325
|
8
8
|
README.md,sha256=Od69x-RS85Hph0-WwWACwal4yUd67XkEn4APEfHhHFw,2649
|
9
|
-
pyproject.toml,sha256=
|
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=
|
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
|
@@ -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
|
@@ -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=
|
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
|
@@ -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=
|
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.
|
404
|
-
bec_widgets-0.
|
405
|
-
bec_widgets-0.
|
406
|
-
bec_widgets-0.
|
407
|
-
bec_widgets-0.
|
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
|
````
|
Binary file
|
Binary file
|
pyproject.toml
CHANGED
@@ -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")
|
File without changes
|
File without changes
|
File without changes
|