bec-widgets 1.22.0__py3-none-any.whl → 1.23.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 CHANGED
@@ -1,6 +1,14 @@
1
1
  # CHANGELOG
2
2
 
3
3
 
4
+ ## v1.23.0 (2025-02-24)
5
+
6
+ ### Features
7
+
8
+ - **bec_spin_box**: Double spin box with setting inside for defining decimals
9
+ ([`f19d948`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/f19d9485df403cb755315ac1a0ff4402d7a85f77))
10
+
11
+
4
12
  ## v1.22.0 (2025-02-19)
5
13
 
6
14
  ### Bug Fixes
PKG-INFO CHANGED
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bec_widgets
3
- Version: 1.22.0
3
+ Version: 1.23.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
File without changes
@@ -0,0 +1 @@
1
+ {'files': ['decimal_spinbox.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.utility.spinbox.decimal_spinbox import BECSpinBox
8
+
9
+ DOM_XML = """
10
+ <ui language='c++'>
11
+ <widget class='BECSpinBox' name='bec_spin_box'>
12
+ </widget>
13
+ </ui>
14
+ """
15
+
16
+
17
+ class BECSpinBoxPlugin(QDesignerCustomWidgetInterface): # pragma: no cover
18
+ def __init__(self):
19
+ super().__init__()
20
+ self._form_editor = None
21
+
22
+ def createWidget(self, parent):
23
+ t = BECSpinBox(parent)
24
+ return t
25
+
26
+ def domXml(self):
27
+ return DOM_XML
28
+
29
+ def group(self):
30
+ return ""
31
+
32
+ def icon(self):
33
+ return designer_material_icon(BECSpinBox.ICON_NAME)
34
+
35
+ def includeFile(self):
36
+ return "bec_spin_box"
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 "BECSpinBox"
49
+
50
+ def toolTip(self):
51
+ return "BECSpinBox"
52
+
53
+ def whatsThis(self):
54
+ return self.toolTip()
@@ -0,0 +1,83 @@
1
+ import sys
2
+
3
+ from bec_qthemes import material_icon
4
+ from qtpy.QtGui import Qt
5
+ from qtpy.QtWidgets import (
6
+ QApplication,
7
+ QDoubleSpinBox,
8
+ QInputDialog,
9
+ QSizePolicy,
10
+ QToolButton,
11
+ QWidget,
12
+ )
13
+
14
+ from bec_widgets.utils import ConnectionConfig
15
+ from bec_widgets.utils.bec_widget import BECWidget
16
+
17
+
18
+ class BECSpinBox(BECWidget, QDoubleSpinBox):
19
+ PLUGIN = True
20
+ RPC = False
21
+ ICON_NAME = "123"
22
+
23
+ def __init__(
24
+ self,
25
+ parent: QWidget | None = None,
26
+ config: ConnectionConfig | None = None,
27
+ client=None,
28
+ gui_id: str | None = None,
29
+ ) -> None:
30
+ if config is None:
31
+ config = ConnectionConfig(widget_class=self.__class__.__name__)
32
+ super().__init__(client=client, gui_id=gui_id, config=config)
33
+ QDoubleSpinBox.__init__(self, parent=parent)
34
+
35
+ self.setObjectName("BECSpinBox")
36
+ # Make the widget as compact as possible horizontally.
37
+ self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
38
+ self.setAlignment(Qt.AlignHCenter)
39
+
40
+ # Configure default QDoubleSpinBox settings.
41
+ self.setRange(-2147483647, 2147483647)
42
+ self.setDecimals(2)
43
+
44
+ # Create an embedded settings button.
45
+ self.setting_button = QToolButton(self)
46
+ self.setting_button.setIcon(material_icon("settings"))
47
+ self.setting_button.setToolTip("Set number of decimals")
48
+ self.setting_button.setCursor(Qt.PointingHandCursor)
49
+ self.setting_button.setFocusPolicy(Qt.NoFocus)
50
+ self.setting_button.setStyleSheet("QToolButton { border: none; padding: 0px; }")
51
+
52
+ self.setting_button.clicked.connect(self.change_decimals)
53
+
54
+ self._button_size = 12
55
+ self._arrow_width = 20
56
+
57
+ def resizeEvent(self, event):
58
+ super().resizeEvent(event)
59
+ arrow_width = self._arrow_width
60
+
61
+ # Position the settings button inside the spin box, to the left of the arrow buttons.
62
+ x = self.width() - arrow_width - self._button_size - 2 # 2px margin
63
+ y = (self.height() - self._button_size) // 2
64
+ self.setting_button.setFixedSize(self._button_size, self._button_size)
65
+ self.setting_button.move(x, y)
66
+
67
+ def change_decimals(self):
68
+ """
69
+ Change the number of decimals in the spin box.
70
+ """
71
+ current = self.decimals()
72
+ new_decimals, ok = QInputDialog.getInt(
73
+ self, "Set Decimals", "Number of decimals:", current, 0, 10, 1
74
+ )
75
+ if ok:
76
+ self.setDecimals(new_decimals)
77
+
78
+
79
+ if __name__ == "__main__": # pragma: no cover
80
+ app = QApplication(sys.argv)
81
+ window = BECSpinBox()
82
+ window.show()
83
+ sys.exit(app.exec())
@@ -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.utility.spinbox.bec_spin_box_plugin import BECSpinBoxPlugin
10
+
11
+ QPyDesignerCustomWidgetCollection.addCustomWidget(BECSpinBoxPlugin())
12
+
13
+
14
+ if __name__ == "__main__": # pragma: no cover
15
+ main()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bec_widgets
3
- Version: 1.22.0
3
+ Version: 1.23.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=PuL-FmkTHm7qs467Mh9D8quWcEj4tgEA-UUGDieMuWk,8774
3
3
  .pylintrc,sha256=eeY8YwSI74oFfq6IYIbCqnx3Vk8ZncKaatv96n_Y8Rs,18544
4
4
  .readthedocs.yaml,sha256=aSOc277LqXcsTI6lgvm_JY80lMlr69GbPKgivua2cS0,603
5
- CHANGELOG.md,sha256=I0VXV76hN6hH8JX7l9F5OXVqbuenWClNEslZF43a6yU,230360
5
+ CHANGELOG.md,sha256=areIe8x_CISa3v2AYaePk8DGFWijiSCy-ILBAZGrYdA,230584
6
6
  LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
7
- PKG-INFO,sha256=AoFfQtO1XAwk8aXaYDJs2ZBxHxPbxVKUbwOVXpQAkJw,1173
7
+ PKG-INFO,sha256=WcdVimfKWBYa3l0ifogd51I_0VM7a9qy1uAOAj4oeEU,1173
8
8
  README.md,sha256=KgdKusjlvEvFtdNZCeDMO91y77MWK2iDcYMDziksOr4,2553
9
- pyproject.toml,sha256=HVH5bV4UEM4smaSNq_bv0FAjv14NavzQ0xGE3K1r_sk,2540
9
+ pyproject.toml,sha256=BUpfPrJNoboBinXX3OGzf4SD1ImSX6TqmS179jRRMXI,2540
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
@@ -325,6 +325,11 @@ bec_widgets/widgets/utility/logpanel/log_panel.pyproject,sha256=2ncs1bsu-wICstR1
325
325
  bec_widgets/widgets/utility/logpanel/log_panel_plugin.py,sha256=KY7eS1uGZzLYtDAdBv6S2mw8UjcDGVt3UklN_D5M06A,1250
326
326
  bec_widgets/widgets/utility/logpanel/logpanel.py,sha256=jMQKn5O7qUFkN-2YnQ3HY7vSf8LIH5ox-T1E_lL3zfQ,19675
327
327
  bec_widgets/widgets/utility/logpanel/register_log_panel.py,sha256=LFUE5JzCYvIwJQtTqZASLVAHYy3gO1nrHzPVH_kpCEY,470
328
+ bec_widgets/widgets/utility/spinbox/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
329
+ bec_widgets/widgets/utility/spinbox/bec_spin_box.pyproject,sha256=RIg1SZuCltuZZuK1O4Djg0TpCInhoCw8KeqNaf1_K0A,33
330
+ bec_widgets/widgets/utility/spinbox/bec_spin_box_plugin.py,sha256=-XNrUAz1LZQPhJrH1sszfGrpBfpHUIfNO4bw7MPcc3k,1255
331
+ bec_widgets/widgets/utility/spinbox/decimal_spinbox.py,sha256=JhTh4Iz_7Hv69G4kksdpa1QZihtAzqaYlkWf3v-SGN8,2671
332
+ bec_widgets/widgets/utility/spinbox/register_bec_spin_box.py,sha256=_whARPM42TCYV_rUBtThGUK7XC1VoIwRn8fVHzxI2pc,476
328
333
  bec_widgets/widgets/utility/spinner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
329
334
  bec_widgets/widgets/utility/spinner/register_spinner_widget.py,sha256=96A13dEcyTgXfc9G0sTdlXYCDcVav8Z2P2eDC95bESQ,484
330
335
  bec_widgets/widgets/utility/spinner/spinner.py,sha256=6c0fN7mdGzELg4mf_yG08ubses3svb6w0EqMeHDFkIw,2651
@@ -356,8 +361,8 @@ bec_widgets/widgets/utility/visual/dark_mode_button/dark_mode_button.py,sha256=Z
356
361
  bec_widgets/widgets/utility/visual/dark_mode_button/dark_mode_button.pyproject,sha256=Lbi9zb6HNlIq14k6hlzR-oz6PIFShBuF7QxE6d87d64,34
357
362
  bec_widgets/widgets/utility/visual/dark_mode_button/dark_mode_button_plugin.py,sha256=CzChz2SSETYsR8-36meqWnsXCT-FIy_J_xeU5coWDY8,1350
358
363
  bec_widgets/widgets/utility/visual/dark_mode_button/register_dark_mode_button.py,sha256=rMpZ1CaoucwobgPj1FuKTnt07W82bV1GaSYdoqcdMb8,521
359
- bec_widgets-1.22.0.dist-info/METADATA,sha256=AoFfQtO1XAwk8aXaYDJs2ZBxHxPbxVKUbwOVXpQAkJw,1173
360
- bec_widgets-1.22.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
361
- bec_widgets-1.22.0.dist-info/entry_points.txt,sha256=dItMzmwA1wizJ1Itx15qnfJ0ZzKVYFLVJ1voxT7K7D4,214
362
- bec_widgets-1.22.0.dist-info/licenses/LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
363
- bec_widgets-1.22.0.dist-info/RECORD,,
364
+ bec_widgets-1.23.0.dist-info/METADATA,sha256=WcdVimfKWBYa3l0ifogd51I_0VM7a9qy1uAOAj4oeEU,1173
365
+ bec_widgets-1.23.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
366
+ bec_widgets-1.23.0.dist-info/entry_points.txt,sha256=dItMzmwA1wizJ1Itx15qnfJ0ZzKVYFLVJ1voxT7K7D4,214
367
+ bec_widgets-1.23.0.dist-info/licenses/LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
368
+ bec_widgets-1.23.0.dist-info/RECORD,,
pyproject.toml CHANGED
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "bec_widgets"
7
- version = "1.22.0"
7
+ version = "1.23.0"
8
8
  description = "BEC Widgets"
9
9
  requires-python = ">=3.10"
10
10
  classifiers = [