Skip to content

Commit af56583

Browse files
committed
added text message box instead of printing ot console
1 parent 8aa980b commit af56583

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/loctight.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ def lock_workstation():
4242
return # Success, exit function
4343
except (subprocess.CalledProcessError, FileNotFoundError):
4444
continue # Try next locker
45-
# If all fail, print error but don't crash
46-
print("Warning: Could not lock screen. No supported screen locker found.")
45+
# If all fail, show warning but don't crash
46+
messagebox.showwarning(
47+
"Screen Lock Failed",
48+
"Could not lock screen. No supported screen locker found.",
49+
)
4750
elif platform == "darwin":
4851
subprocess.run(
4952
[

tests/test_core_logic.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ def test_linux_lock_fallback_mechanism(self, mock_subprocess):
267267

268268
@patch("src.loctight.subprocess.run")
269269
@patch("src.loctight.platform", "linux")
270-
@patch("builtins.print")
271-
def test_linux_lock_all_fail(self, mock_print, mock_subprocess):
270+
@patch("src.loctight.messagebox.showwarning")
271+
def test_linux_lock_all_fail(self, mock_messagebox, mock_subprocess):
272272
"""Test Linux lock handles all lockers failing gracefully"""
273273
from src.loctight import lock_workstation
274274

@@ -279,9 +279,10 @@ def test_linux_lock_all_fail(self, mock_print, mock_subprocess):
279279

280280
# Should have tried all 5 lockers
281281
self.assertEqual(mock_subprocess.call_count, 5)
282-
# Should print warning message
283-
mock_print.assert_called_once_with(
284-
"Warning: Could not lock screen. No supported screen locker found."
282+
# Should show warning messagebox
283+
mock_messagebox.assert_called_once_with(
284+
"Screen Lock Failed",
285+
"Could not lock screen. No supported screen locker found.",
285286
)
286287

287288

0 commit comments

Comments
 (0)