bec-widgets 1.15.0__py3-none-any.whl → 1.15.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,6 +1,14 @@
1
1
  # CHANGELOG
2
2
 
3
3
 
4
+ ## v1.15.1 (2025-01-13)
5
+
6
+ ### Bug Fixes
7
+
8
+ - **error_popups**: Safeproperty wrapper extended to catch more errors and not crash Designer
9
+ ([`3b04b98`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/3b04b985b66a7237703a87f6a53610171eb9ffa5))
10
+
11
+
4
12
  ## v1.15.0 (2025-01-10)
5
13
 
6
14
  ### Features
PKG-INFO CHANGED
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bec_widgets
3
- Version: 1.15.0
3
+ Version: 1.15.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,25 +2,52 @@ import functools
2
2
  import sys
3
3
  import traceback
4
4
 
5
+ from bec_lib.logger import bec_logger
5
6
  from qtpy.QtCore import Property, QObject, Qt, Signal, Slot
6
7
  from qtpy.QtWidgets import QApplication, QMessageBox, QPushButton, QVBoxLayout, QWidget
7
8
 
8
9
 
9
- def SafeProperty(prop_type, *prop_args, popup_error: bool = False, **prop_kwargs):
10
+ def SafeProperty(prop_type, *prop_args, popup_error: bool = False, default=None, **prop_kwargs):
10
11
  """
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.
12
+ Decorator to create a Qt Property with safe getter and setter so that
13
+ Qt Designer won't crash if an exception occurs in either method.
13
14
 
14
15
  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.
16
+ prop_type: The property type (e.g., str, bool, int, custom classes, etc.)
17
+ popup_error (bool): If True, show a popup for any error; otherwise, ignore or log silently.
18
+ default: Any default/fallback value to return if the getter raises an exception.
19
+ *prop_args, **prop_kwargs: Passed along to the underlying Qt Property constructor.
20
+
21
+ Usage:
22
+ @SafeProperty(int, default=-1)
23
+ def some_value(self) -> int:
24
+ # your getter logic
25
+ return ... # if an exception is raised, returns -1
26
+
27
+ @some_value.setter
28
+ def some_value(self, val: int):
29
+ # your setter logic
30
+ ...
18
31
  """
19
32
 
20
- def decorator(getter):
33
+ def decorator(py_getter):
34
+ @functools.wraps(py_getter)
35
+ def safe_getter(self_):
36
+ try:
37
+ return py_getter(self_)
38
+ except Exception:
39
+ if popup_error:
40
+ ErrorPopupUtility().custom_exception_hook(*sys.exc_info(), popup_error=True)
41
+ # Return the user-defined default (which might be anything, including None).
42
+ else:
43
+ error_msg = traceback.format_exc()
44
+ bec_logger.error(error_msg)
45
+ return default
46
+
21
47
  class PropertyWrapper:
22
48
  def __init__(self, getter_func):
23
- self.getter_func = getter_func
49
+ # We store only our safe_getter in the wrapper
50
+ self.getter_func = safe_getter
24
51
 
25
52
  def setter(self, setter_func):
26
53
  @functools.wraps(setter_func)
@@ -32,12 +59,20 @@ def SafeProperty(prop_type, *prop_args, popup_error: bool = False, **prop_kwargs
32
59
  ErrorPopupUtility().custom_exception_hook(
33
60
  *sys.exc_info(), popup_error=True
34
61
  )
62
+ # Swallow the exception; no crash in Designer
35
63
  else:
36
- return
64
+ error_msg = traceback.format_exc()
65
+ bec_logger.error(error_msg)
66
+ return
37
67
 
68
+ # Return the full read/write Property
38
69
  return Property(prop_type, self.getter_func, safe_setter, *prop_args, **prop_kwargs)
39
70
 
40
- return PropertyWrapper(getter)
71
+ def __call__(self):
72
+ # If the user never chains a .setter(...) call, we produce a read-only property
73
+ return Property(prop_type, self.getter_func, None, *prop_args, **prop_kwargs)
74
+
75
+ return PropertyWrapper(py_getter)
41
76
 
42
77
  return decorator
43
78
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bec_widgets
3
- Version: 1.15.0
3
+ Version: 1.15.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=CLlFGYRGKp4FxCPTkyF9p-7qx67KmbM9Yok9JQEU_Ls,8677
3
3
  .pylintrc,sha256=eeY8YwSI74oFfq6IYIbCqnx3Vk8ZncKaatv96n_Y8Rs,18544
4
4
  .readthedocs.yaml,sha256=aSOc277LqXcsTI6lgvm_JY80lMlr69GbPKgivua2cS0,603
5
- CHANGELOG.md,sha256=849MrBPqJXJ8uZuRcBjlPsxjve-_HmdJgibe27FENaQ,221333
5
+ CHANGELOG.md,sha256=PLH7TxQeADnLcLJvCxY8y4eWlHYlibflQw4N5agOy4Q,221574
6
6
  LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
7
- PKG-INFO,sha256=yGSseM2wz5VSWKYD2XZ9RLsaXmX7WMfNwjh-HWMkJwE,1339
7
+ PKG-INFO,sha256=eSWz36E758Ec4tYRAAudPgBBJ8yqKTijz2DjCULvlrk,1339
8
8
  README.md,sha256=Od69x-RS85Hph0-WwWACwal4yUd67XkEn4APEfHhHFw,2649
9
- pyproject.toml,sha256=1cn7PLlXgQgF3kW2-a6mRnuCb4SD0wTYspJB2CLTE0A,2596
9
+ pyproject.toml,sha256=vSsp1CG05ZIaEzBiIEtCyrXDUgHzET42kuJBJvDkpqE,2596
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
@@ -49,7 +49,7 @@ bec_widgets/examples/plugin_example_pyside/tictactoetaskmenu.py,sha256=V6OVnBTS-
49
49
  bec_widgets/qt_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
50
50
  bec_widgets/qt_utils/collapsible_panel_manager.py,sha256=tvv77-9YTfYpsU6M_Le3bHR6wtANC83DEOrJ2Hhj6rs,14201
51
51
  bec_widgets/qt_utils/compact_popup.py,sha256=3yeb-GJ1PUla5Q_hT0XDKqvyIEH9yV_eGidf1t8Dbbw,10234
52
- bec_widgets/qt_utils/error_popups.py,sha256=Bm5-Gjl_vELFo12f8KgGRlk4hCCT9hfwGM7ggmvfCFs,9323
52
+ bec_widgets/qt_utils/error_popups.py,sha256=yVJ2sPOji5rUWEy7BgIEXUzvNQiw2njsaGhW6Hv_dx0,10828
53
53
  bec_widgets/qt_utils/palette_viewer.py,sha256=--B0x7aE7bniHIeuuLY_pH8yBDrTTXaE0IDrC_AM1mo,6326
54
54
  bec_widgets/qt_utils/redis_message_waiter.py,sha256=fvL_QgC0cTDv_FPJdRyp5AKjf401EJU4z3r38p47ydY,1745
55
55
  bec_widgets/qt_utils/round_frame.py,sha256=Ba_sTzYB_vYDepBBMPPqU8XDwKOAiU6ClZ3xUqiveK0,5734
@@ -326,8 +326,8 @@ bec_widgets/widgets/utility/visual/dark_mode_button/dark_mode_button.py,sha256=Z
326
326
  bec_widgets/widgets/utility/visual/dark_mode_button/dark_mode_button.pyproject,sha256=Lbi9zb6HNlIq14k6hlzR-oz6PIFShBuF7QxE6d87d64,34
327
327
  bec_widgets/widgets/utility/visual/dark_mode_button/dark_mode_button_plugin.py,sha256=CzChz2SSETYsR8-36meqWnsXCT-FIy_J_xeU5coWDY8,1350
328
328
  bec_widgets/widgets/utility/visual/dark_mode_button/register_dark_mode_button.py,sha256=rMpZ1CaoucwobgPj1FuKTnt07W82bV1GaSYdoqcdMb8,521
329
- bec_widgets-1.15.0.dist-info/METADATA,sha256=yGSseM2wz5VSWKYD2XZ9RLsaXmX7WMfNwjh-HWMkJwE,1339
330
- bec_widgets-1.15.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
331
- bec_widgets-1.15.0.dist-info/entry_points.txt,sha256=dItMzmwA1wizJ1Itx15qnfJ0ZzKVYFLVJ1voxT7K7D4,214
332
- bec_widgets-1.15.0.dist-info/licenses/LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
333
- bec_widgets-1.15.0.dist-info/RECORD,,
329
+ bec_widgets-1.15.1.dist-info/METADATA,sha256=eSWz36E758Ec4tYRAAudPgBBJ8yqKTijz2DjCULvlrk,1339
330
+ bec_widgets-1.15.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
331
+ bec_widgets-1.15.1.dist-info/entry_points.txt,sha256=dItMzmwA1wizJ1Itx15qnfJ0ZzKVYFLVJ1voxT7K7D4,214
332
+ bec_widgets-1.15.1.dist-info/licenses/LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
333
+ bec_widgets-1.15.1.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.15.0"
7
+ version = "1.15.1"
8
8
  description = "BEC Widgets"
9
9
  requires-python = ">=3.10"
10
10
  classifiers = [