Skip to content

Commit a5ad3f8

Browse files
committed
feat(auto_start): 使用 Windows 通知替代消息框
- 添加 win10toast 模块以支持 Windows 通知 - 在首次启动时显示布局提示或警告,优先使用通知方式
1 parent 1bae274 commit a5ad3f8

File tree

2 files changed

+38
-11
lines changed

2 files changed

+38
-11
lines changed

auto_start.py

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
from constants import DEFAULT_GEOMETRY, CONFIG_FILE, RESOLUTION_PRESETS
1414
from logger import logger
1515

16+
try:
17+
from win10toast import ToastNotifier
18+
except ImportError:
19+
ToastNotifier = None
20+
1621
# 在子进程中运行分辨率读取函数
1722
def get_screen_resolution_worker(queue):
1823
"""获取主显示器分辨率并放入队列"""
@@ -129,18 +134,40 @@ def check_and_generate_files():
129134
logger.log_info(f"Setting initial geometry to: {optimal_geometry} (match type: {match_type})")
130135

131136
if match_type == "exact":
132-
messagebox.showinfo(
133-
"布局提示",
134-
"首次启动,已为您自动匹配预设的窗口布局。\n"
135-
"如果布局不符合您的习惯,请在“设置”中进行调整。"
136-
)
137+
if ToastNotifier:
138+
toaster = ToastNotifier()
139+
toaster.show_toast(
140+
"布局提示",
141+
"首次启动,已为您自动匹配预设的窗口布局。\n如果布局不符合您的习惯,请在“设置”中进行调整。",
142+
icon_path="res/icon.ico",
143+
duration=10,
144+
threaded=True
145+
)
146+
else:
147+
# Fallback to original messagebox if win10toast is not available
148+
messagebox.showinfo(
149+
"布局提示",
150+
"首次启动,已为您自动匹配预设的窗口布局。\n"
151+
"如果布局不符合您的习惯,请在“设置”中进行调整。"
152+
)
137153
else: # 'fallback' or 'default'
138-
messagebox.showwarning(
139-
"布局警告",
140-
"首次启动,未能找到完全匹配您屏幕的预设布局。\n"
141-
"当前使用的是一个近似或默认的方案,可能不准确。\n"
142-
"请务必在“设置”中根据您的偏好进行调整!"
143-
)
154+
if ToastNotifier:
155+
toaster = ToastNotifier()
156+
toaster.show_toast(
157+
"布局警告",
158+
"首次启动,未能找到完全匹配您屏幕的预设布局。\n当前使用的是一个近似或默认的方案,可能不准确。\n请务必在“设置”中根据您的偏好进行调整!",
159+
icon_path="res/icon.ico",
160+
duration=10,
161+
threaded=True
162+
)
163+
else:
164+
# Fallback to original messagebox
165+
messagebox.showwarning(
166+
"布局警告",
167+
"首次启动,未能找到完全匹配您屏幕的预设布局。\n"
168+
"当前使用的是一个近似或默认的方案,可能不准确。\n"
169+
"请务必在“设置”中根据您的偏好进行调整!"
170+
)
144171

145172
default_config = {
146173
"geometry": optimal_geometry,

requirements.txt

24 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)