fix: Clean up code by removing unnecessary blank lines

- Removed excessive blank lines from various markdown and Python files to enhance readability and maintainability.
- Ensured consistent formatting across documentation and code files, improving overall project clarity.
This commit is contained in:
Your Name committed 2025-12-25 16:55:44 +08:00
1 parent c30b73bbd3
commit 29f7b19916
35 files changed
+7809 -278

No files matched your search

+210 -2
View File
@@ -1713,12 +1713,124 @@ def main():
# 日志区
log_box = ttk.Frame(log_tab)
log_box.pack(fill=BOTH, expand=True)
# 搜索工具栏
log_search_frame = ttk.Frame(log_box)
log_search_frame.pack(fill=X, padx=10, pady=(10, 5))
log_search_var = tk.StringVar(value="")
log_search_entry = ttk.Entry(log_search_frame, textvariable=log_search_var, width=20)
log_search_entry.pack(side=LEFT, padx=(0, 5))
log_search_matches = [] # 存储所有匹配的位置
log_current_match_index = -1 # 当前匹配的索引
def search_in_log_text(direction=1):
"""在运行日志中搜索文本"""
nonlocal log_search_matches, log_current_match_index
search_text = log_search_var.get().strip()
if not search_text:
# 清除高亮
log_text.tag_remove("search_highlight", "1.0", "end")
log_search_matches = []
log_current_match_index = -1
return
# 获取所有文本
content = log_text.get("1.0", "end-1c")
if not content:
return
# 清除之前的高亮
log_text.tag_remove("search_highlight", "1.0", "end")
log_text.tag_remove("search_current", "1.0", "end")
# 配置高亮样式
log_text.tag_config("search_highlight", background="yellow")
log_text.tag_config("search_current", background="orange")
# 查找所有匹配项(不区分大小写)
log_search_matches = []
start_pos = 0 # 使用整数索引
search_text_lower = search_text.lower()
content_lower = content.lower()
while True:
# 在内容中查找
pos = content_lower.find(search_text_lower, start_pos)
if pos == -1:
break
# 计算行号和列号
line_start = content[:pos].rfind("\n") + 1
line_num = content[:pos].count("\n") + 1
col_num = pos - line_start
# 转换为 tkinter 索引格式
start_index = f"{line_num}.{col_num}"
end_index = f"{line_num}.{col_num + len(search_text)}"
log_search_matches.append((start_index, end_index))
start_pos = pos + 1
if not log_search_matches:
# 没有找到匹配项
log_current_match_index = -1
return
# 高亮所有匹配项
for start_idx, end_idx in log_search_matches:
log_text.tag_add("search_highlight", start_idx, end_idx)
# 根据方向更新当前匹配索引
if direction == 1: # 下一个
log_current_match_index = (log_current_match_index + 1) % len(log_search_matches)
else: # 上一个
log_current_match_index = (log_current_match_index - 1) % len(log_search_matches)
# 高亮当前匹配项并滚动到该位置
if log_current_match_index >= 0:
start_idx, end_idx = log_search_matches[log_current_match_index]
log_text.tag_add("search_current", start_idx, end_idx)
log_text.see(start_idx)
log_text.mark_set("insert", start_idx)
def search_next_in_log():
"""搜索下一个"""
search_in_log_text(1)
def search_prev_in_log():
"""搜索上一个"""
search_in_log_text(-1)
def clear_search_in_log():
"""清除搜索高亮"""
nonlocal log_search_matches, log_current_match_index
log_search_var.set("")
log_text.tag_remove("search_highlight", "1.0", "end")
log_text.tag_remove("search_current", "1.0", "end")
log_search_matches = []
log_current_match_index = -1
# 绑定回车键搜索
def on_log_search_entry_key(event):
if event.keysym == "Return":
search_next_in_log()
log_search_entry.bind("<KeyPress>", on_log_search_entry_key)
ttk.Button(log_search_frame, text="搜索", command=search_next_in_log).pack(side=LEFT, padx=(0, 2))
ttk.Button(log_search_frame, text="上一个", command=search_prev_in_log).pack(side=LEFT, padx=(0, 2))
ttk.Button(log_search_frame, text="下一个", command=search_next_in_log).pack(side=LEFT, padx=(0, 2))
ttk.Button(log_search_frame, text="清除", command=clear_search_in_log).pack(side=LEFT, padx=(0, 5))
log_text = ScrolledText(log_box)
try:
log_text.configure(font=("Consolas", 10))
except Exception:
pass
log_text.pack(fill=BOTH, expand=True, padx=10, pady=10)
log_text.pack(fill=BOTH, expand=True, padx=10, pady=(0, 10))
# 截图预览
preview_top = ttk.Frame(preview_tab)
@@ -2570,8 +2682,104 @@ def main():
side=LEFT, padx=(0, 8)
)
ttk.Button(actions_log_top, text="刷新", command=refresh_actions_log).pack(
side=LEFT
side=LEFT, padx=(0, 10)
)
# 行为日志搜索功能
ttk.Separator(actions_log_top, orient="vertical").pack(side=LEFT, fill=Y, padx=5, pady=3)
ttk.Label(actions_log_top, text="搜索:").pack(side=LEFT)
actions_search_var = tk.StringVar(value="")
actions_search_entry = ttk.Entry(actions_log_top, textvariable=actions_search_var, width=20)
actions_search_entry.pack(side=LEFT, padx=(0, 5))
actions_search_matches = []
actions_current_match_index = -1
def search_in_actions_log(direction=1):
"""在行为日志中搜索文本"""
nonlocal actions_search_matches, actions_current_match_index
search_text = actions_search_var.get().strip()
if not search_text:
actions_log_text.tag_remove("search_highlight", "1.0", "end")
actions_log_text.tag_remove("search_current", "1.0", "end")
actions_search_matches = []
actions_current_match_index = -1
return
content = actions_log_text.get("1.0", "end-1c")
if not content:
return
actions_log_text.tag_remove("search_highlight", "1.0", "end")
actions_log_text.tag_remove("search_current", "1.0", "end")
actions_log_text.tag_config("search_highlight", background="yellow")
actions_log_text.tag_config("search_current", background="orange")
actions_search_matches = []
start_pos = 0 # 使用整数索引
search_text_lower = search_text.lower()
content_lower = content.lower()
while True:
pos = content_lower.find(search_text_lower, start_pos)
if pos == -1:
break
line_start = content[:pos].rfind("\n") + 1
line_num = content[:pos].count("\n") + 1
col_num = pos - line_start
start_index = f"{line_num}.{col_num}"
end_index = f"{line_num}.{col_num + len(search_text)}"
actions_search_matches.append((start_index, end_index))
start_pos = pos + 1
if not actions_search_matches:
actions_current_match_index = -1
return
for start_idx, end_idx in actions_search_matches:
actions_log_text.tag_add("search_highlight", start_idx, end_idx)
if direction == 1:
actions_current_match_index = (actions_current_match_index + 1) % len(actions_search_matches)
else:
actions_current_match_index = (actions_current_match_index - 1) % len(actions_search_matches)
if actions_current_match_index >= 0:
start_idx, end_idx = actions_search_matches[actions_current_match_index]
actions_log_text.tag_add("search_current", start_idx, end_idx)
actions_log_text.see(start_idx)
actions_log_text.mark_set("insert", start_idx)
def search_next_in_actions():
search_in_actions_log(1)
def search_prev_in_actions():
search_in_actions_log(-1)
def clear_search_in_actions():
nonlocal actions_search_matches, actions_current_match_index
actions_search_var.set("")
actions_log_text.tag_remove("search_highlight", "1.0", "end")
actions_log_text.tag_remove("search_current", "1.0", "end")
actions_search_matches = []
actions_current_match_index = -1
def on_actions_search_entry_key(event):
if event.keysym == "Return":
search_next_in_actions()
actions_search_entry.bind("<KeyPress>", on_actions_search_entry_key)
ttk.Button(actions_log_top, text="搜索", command=search_next_in_actions).pack(side=LEFT, padx=(0, 2))
ttk.Button(actions_log_top, text="上一个", command=search_prev_in_actions).pack(side=LEFT, padx=(0, 2))
ttk.Button(actions_log_top, text="下一个", command=search_next_in_actions).pack(side=LEFT, padx=(0, 2))
ttk.Button(actions_log_top, text="清除", command=clear_search_in_actions).pack(side=LEFT)
# OCR结果显示
ocr_results_top = ttk.Frame(ocr_results_tab)