refactor: 优化倒计时逻辑,移除多余的时间修正,调整相关日志记录
This commit is contained in:
1 parent
d100ac0a66
commit
bffca95af0
7 files changed
+115
-47
No files matched your search
+85
-8
@@ -2206,6 +2206,23 @@ def main():
|
||||
# 右侧:Notebook(日志 / 截图预览 / 统计信息 / 预约队列 / 高价值房间)
|
||||
notebook = ttk.Notebook(right)
|
||||
|
||||
# 实时状态工具栏(固定在 Notebook 上方,始终可见)
|
||||
show_actions_var = tk.BooleanVar(value=True)
|
||||
show_screenshot_var = tk.BooleanVar(value=False)
|
||||
auto_scroll_var = tk.BooleanVar(value=True)
|
||||
|
||||
realtime_tools = ttk.Frame(right)
|
||||
realtime_tools.pack(fill=X, padx=8, pady=(4, 0))
|
||||
ttk.Checkbutton(
|
||||
realtime_tools, text="显示动作流", variable=show_actions_var
|
||||
).pack(side=LEFT, padx=(0, 8))
|
||||
ttk.Checkbutton(
|
||||
realtime_tools, text="显示截图", variable=show_screenshot_var
|
||||
).pack(side=LEFT, padx=(0, 8))
|
||||
ttk.Checkbutton(
|
||||
realtime_tools, text="自动滚动", variable=auto_scroll_var
|
||||
).pack(side=LEFT, padx=(0, 8))
|
||||
|
||||
log_tab = ttk.Frame(notebook)
|
||||
preview_tab = ttk.Frame(notebook)
|
||||
stats_tab = ttk.Frame(notebook)
|
||||
@@ -2234,7 +2251,13 @@ def main():
|
||||
realtime_frame = ttk.Frame(realtime_tab)
|
||||
realtime_frame.pack(fill=BOTH, expand=True, padx=8, pady=8)
|
||||
|
||||
realtime_text = ScrolledText(realtime_frame, height=20)
|
||||
|
||||
|
||||
# 截图预览区域(根据选项显示/隐藏)
|
||||
image_label = ttk.Label(realtime_frame)
|
||||
image_label.pack(fill=X)
|
||||
|
||||
realtime_text = ScrolledText(realtime_frame, height=14)
|
||||
realtime_text.pack(fill=BOTH, expand=True)
|
||||
realtime_text.configure(state="disabled")
|
||||
|
||||
@@ -2309,14 +2332,68 @@ def main():
|
||||
|
||||
parsed = list(reversed(parsed))
|
||||
|
||||
realtime_text.configure(state="normal")
|
||||
realtime_text.delete("1.0", "end")
|
||||
if not parsed:
|
||||
realtime_text.insert("1.0", "暂无动作日志(仅显示包含“耗时”的行)")
|
||||
# 更新截图(若选中)
|
||||
if show_screenshot_var.get():
|
||||
try:
|
||||
try:
|
||||
from path_config import get_screenshot_path
|
||||
|
||||
screenshot_path = get_screenshot_path()
|
||||
except Exception:
|
||||
import path_config
|
||||
|
||||
screenshot_path = path_config.get_screenshot_path()
|
||||
|
||||
if os.path.exists(screenshot_path):
|
||||
img = Image.open(screenshot_path)
|
||||
# 缩放以适应宽度(保持纵横比),最大宽度 420
|
||||
max_w = 420
|
||||
w, h = img.size
|
||||
if w > max_w:
|
||||
nw = max_w
|
||||
nh = int(h * (nw / w))
|
||||
img = img.resize((nw, nh), Image.LANCZOS)
|
||||
tk_img = ImageTk.PhotoImage(img)
|
||||
image_label.configure(image=tk_img)
|
||||
image_label.image = tk_img
|
||||
image_label.pack(fill=X)
|
||||
else:
|
||||
image_label.configure(image="")
|
||||
image_label.image = None
|
||||
image_label.pack_forget()
|
||||
except Exception:
|
||||
image_label.configure(image="")
|
||||
image_label.image = None
|
||||
image_label.pack_forget()
|
||||
else:
|
||||
for action, dur in parsed:
|
||||
realtime_text.insert("end", f"{action} {dur}\n")
|
||||
realtime_text.configure(state="disabled")
|
||||
image_label.configure(image="")
|
||||
image_label.image = None
|
||||
image_label.pack_forget()
|
||||
|
||||
# 更新动作流文本(若选中)
|
||||
if show_actions_var.get():
|
||||
realtime_text.configure(state="normal")
|
||||
realtime_text.delete("1.0", "end")
|
||||
if not parsed:
|
||||
realtime_text.insert("1.0", "暂无动作日志(仅显示包含“耗时”的行)")
|
||||
else:
|
||||
for action, dur in parsed:
|
||||
realtime_text.insert("end", f"{action} {dur}\n")
|
||||
# 自动滚动
|
||||
if auto_scroll_var.get():
|
||||
try:
|
||||
realtime_text.see("end")
|
||||
except Exception:
|
||||
try:
|
||||
realtime_text.yview_moveto(1.0)
|
||||
except Exception:
|
||||
pass
|
||||
realtime_text.configure(state="disabled")
|
||||
else:
|
||||
# 隐藏文本内容但保留控件
|
||||
realtime_text.configure(state="normal")
|
||||
realtime_text.delete("1.0", "end")
|
||||
realtime_text.configure(state="disabled")
|
||||
|
||||
# 安排下一次刷新
|
||||
try:
|
||||
|
||||
Reference in new issue
Block a user