bec-widgets 1.11.0__py3-none-any.whl → 1.12.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,15 @@
1
1
  # CHANGELOG
2
2
 
3
3
 
4
+ ## v1.12.0 (2024-12-12)
5
+
6
+ ### Features
7
+
8
+ - **safe_property**: Added decorator to handle errors in Property decorator from qt to not crash
9
+ designer
10
+ ([`e380489`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/e38048964f942f9f4edba225835ad0a937503dd4))
11
+
12
+
4
13
  ## v1.11.0 (2024-12-11)
5
14
 
6
15
  ### Features
@@ -203,11 +212,3 @@ Depending on the test, auto-updates are enabled or not.
203
212
 
204
213
  - **positioner_box**: Adjusted default signals
205
214
  ([`8e5c0ad`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/8e5c0ad8c8eff5a9308169bc663d2b7230f0ebb1))
206
-
207
-
208
- ## v1.4.0 (2024-11-11)
209
-
210
- ### Bug Fixes
211
-
212
- - **crosshair**: Label of coordinates of TextItem displays numbers in general format
213
- ([`11e5937`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/11e5937ae0f3c1413acd4e66878a692ebe4ef7d0))
PKG-INFO CHANGED
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: bec_widgets
3
- Version: 1.11.0
3
+ Version: 1.12.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,10 +2,46 @@ import functools
2
2
  import sys
3
3
  import traceback
4
4
 
5
- from qtpy.QtCore import QObject, Qt, Signal, Slot
5
+ from qtpy.QtCore import Property, QObject, Qt, Signal, Slot
6
6
  from qtpy.QtWidgets import QApplication, QMessageBox, QPushButton, QVBoxLayout, QWidget
7
7
 
8
8
 
9
+ def SafeProperty(prop_type, *prop_args, popup_error: bool = False, **prop_kwargs):
10
+ """
11
+ Decorator to create a Qt Property with a safe setter that won't crash Designer on errors.
12
+ Behaves similarly to SafeSlot, but for properties.
13
+
14
+ Args:
15
+ prop_type: The property type (e.g., str, bool, "QStringList", etc.)
16
+ popup_error (bool): If True, show popup on error, otherwise just handle it silently.
17
+ *prop_args, **prop_kwargs: Additional arguments and keyword arguments accepted by Property.
18
+ """
19
+
20
+ def decorator(getter):
21
+ class PropertyWrapper:
22
+ def __init__(self, getter_func):
23
+ self.getter_func = getter_func
24
+
25
+ def setter(self, setter_func):
26
+ @functools.wraps(setter_func)
27
+ def safe_setter(self_, value):
28
+ try:
29
+ return setter_func(self_, value)
30
+ except Exception:
31
+ if popup_error:
32
+ ErrorPopupUtility().custom_exception_hook(
33
+ *sys.exc_info(), popup_error=True
34
+ )
35
+ else:
36
+ return
37
+
38
+ return Property(prop_type, self.getter_func, safe_setter, *prop_args, **prop_kwargs)
39
+
40
+ return PropertyWrapper(getter)
41
+
42
+ return decorator
43
+
44
+
9
45
  def SafeSlot(*slot_args, **slot_kwargs): # pylint: disable=invalid-name
10
46
  """Function with args, acting like a decorator, applying "error_managed" decorator + Qt Slot
11
47
  to the passed function, to display errors instead of potentially raising an exception
@@ -91,6 +127,12 @@ class _ErrorPopupUtility(QObject):
91
127
  msg.setMinimumHeight(400)
92
128
  msg.exec_()
93
129
 
130
+ def show_property_error(self, title, message, widget):
131
+ """
132
+ Show a property-specific error message.
133
+ """
134
+ self.error_occurred.emit(title, message, widget)
135
+
94
136
  def format_traceback(self, traceback_message: str) -> str:
95
137
  """
96
138
  Format the traceback message to be displayed in the error popup by adding indentation to each line.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: bec_widgets
3
- Version: 1.11.0
3
+ Version: 1.12.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=bAWGX_NR9rQZmv_bmyLXkEMRreWp0JzVNpsNTxk0NwE,8637
3
3
  .pylintrc,sha256=eeY8YwSI74oFfq6IYIbCqnx3Vk8ZncKaatv96n_Y8Rs,18544
4
4
  .readthedocs.yaml,sha256=aSOc277LqXcsTI6lgvm_JY80lMlr69GbPKgivua2cS0,603
5
- CHANGELOG.md,sha256=jXJI2uWGwhsaGyF_V9ngkP30ZoyF3gm3RaSO8RSbZfQ,7602
5
+ CHANGELOG.md,sha256=YUN7cYN4D404UHmCrAwMrlL-4mVl5OViGPzlLVCnYn0,7625
6
6
  LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
7
- PKG-INFO,sha256=QgtqyeZ80BrmFfNphdBTCBs0g17ZZ-pzLaZ14MuV8EY,1309
7
+ PKG-INFO,sha256=1-7w2AujTo1NIogqL1USRHIzs8GGvH5d49N-1KP90kk,1309
8
8
  README.md,sha256=Od69x-RS85Hph0-WwWACwal4yUd67XkEn4APEfHhHFw,2649
9
- pyproject.toml,sha256=PPZ0RXljmNIqxbncdTU8wamWgRyUXXRINs8NHn58TX0,2587
9
+ pyproject.toml,sha256=flzI-4819-LvKYP0njUAltnkKXfJisdhtnUNtCryTXI,2587
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
@@ -47,7 +47,7 @@ bec_widgets/examples/plugin_example_pyside/tictactoetaskmenu.py,sha256=V6OVnBTS-
47
47
  bec_widgets/qt_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
48
  bec_widgets/qt_utils/collapsible_panel_manager.py,sha256=tvv77-9YTfYpsU6M_Le3bHR6wtANC83DEOrJ2Hhj6rs,14201
49
49
  bec_widgets/qt_utils/compact_popup.py,sha256=3yeb-GJ1PUla5Q_hT0XDKqvyIEH9yV_eGidf1t8Dbbw,10234
50
- bec_widgets/qt_utils/error_popups.py,sha256=y9gKKWaafp468ioHr96nBhf02ZpEgjDc-BAVOTWh-e8,7680
50
+ bec_widgets/qt_utils/error_popups.py,sha256=gd63kggSOHRmh9HzSPH2jjQznUecRBhhCtvoGIlh7xA,9253
51
51
  bec_widgets/qt_utils/palette_viewer.py,sha256=--B0x7aE7bniHIeuuLY_pH8yBDrTTXaE0IDrC_AM1mo,6326
52
52
  bec_widgets/qt_utils/redis_message_waiter.py,sha256=fvL_QgC0cTDv_FPJdRyp5AKjf401EJU4z3r38p47ydY,1745
53
53
  bec_widgets/qt_utils/round_frame.py,sha256=Ba_sTzYB_vYDepBBMPPqU8XDwKOAiU6ClZ3xUqiveK0,5734
@@ -318,8 +318,8 @@ bec_widgets/widgets/utility/visual/dark_mode_button/dark_mode_button.py,sha256=Z
318
318
  bec_widgets/widgets/utility/visual/dark_mode_button/dark_mode_button.pyproject,sha256=Lbi9zb6HNlIq14k6hlzR-oz6PIFShBuF7QxE6d87d64,34
319
319
  bec_widgets/widgets/utility/visual/dark_mode_button/dark_mode_button_plugin.py,sha256=CzChz2SSETYsR8-36meqWnsXCT-FIy_J_xeU5coWDY8,1350
320
320
  bec_widgets/widgets/utility/visual/dark_mode_button/register_dark_mode_button.py,sha256=rMpZ1CaoucwobgPj1FuKTnt07W82bV1GaSYdoqcdMb8,521
321
- bec_widgets-1.11.0.dist-info/METADATA,sha256=QgtqyeZ80BrmFfNphdBTCBs0g17ZZ-pzLaZ14MuV8EY,1309
322
- bec_widgets-1.11.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
323
- bec_widgets-1.11.0.dist-info/entry_points.txt,sha256=dItMzmwA1wizJ1Itx15qnfJ0ZzKVYFLVJ1voxT7K7D4,214
324
- bec_widgets-1.11.0.dist-info/licenses/LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
325
- bec_widgets-1.11.0.dist-info/RECORD,,
321
+ bec_widgets-1.12.0.dist-info/METADATA,sha256=1-7w2AujTo1NIogqL1USRHIzs8GGvH5d49N-1KP90kk,1309
322
+ bec_widgets-1.12.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
323
+ bec_widgets-1.12.0.dist-info/entry_points.txt,sha256=dItMzmwA1wizJ1Itx15qnfJ0ZzKVYFLVJ1voxT7K7D4,214
324
+ bec_widgets-1.12.0.dist-info/licenses/LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
325
+ bec_widgets-1.12.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.11.0"
7
+ version = "1.12.0"
8
8
  description = "BEC Widgets"
9
9
  requires-python = ">=3.10"
10
10
  classifiers = [