From 3f203fa489389cd2d8cdc84220b2b64b9b5f3210 Mon Sep 17 00:00:00 2001 From: Fer Date: Mon, 22 Jun 2026 17:01:02 +0200 Subject: [PATCH] Fix error: Traceback (most recent call last): File "./MPCFillToPDF/.venv/lib/python3.12/site-packages/plyer/utils.py", line 96, in _ensure_obj mod = __import__(module, fromlist='.') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "./MPCFillToPDF/.venv/lib/python3.12/site-packages/plyer/platforms/macosx/notification.py", line 7, in from pyobjus import ( ModuleNotFoundError: No module named 'pyobjus' on Mac --- gui/widgets.py | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/gui/widgets.py b/gui/widgets.py index e85a338..795b67a 100644 --- a/gui/widgets.py +++ b/gui/widgets.py @@ -47,13 +47,31 @@ def ellipsize(name: str, width: int) -> str: def notify(title: str, message: str) -> None: - """Show a system notification (best-effort; silently ignored if plyer is missing).""" - try: - from plyer import notification as _n + """Show a system notification (best-effort; silently ignored if plyer/osascript is missing).""" + if sys.platform == "darwin": + try: + import subprocess + + script = ( + "on run argv\n" + " display notification (item 2 of argv) with title (item 1 of argv)\n" + "end run" + ) + subprocess.run( + ["osascript", "-e", script, title, message], + capture_output=True, + check=False, + ) + except Exception: + pass + else: + try: + from plyer import notification as _n + + _n.notify(title=title, message=message, app_name=APP_TITLE, timeout=8) + except Exception: + pass - _n.notify(title=title, message=message, app_name=APP_TITLE, timeout=8) - except Exception: - pass def attach_context_menu(widget: tk.Widget) -> None: