refactor(gui): actions_log + ocr_results 内置到 simple_tabs (450 → 440)
This commit is contained in:
1 parent
a6648c5ce8
commit
8e0ae9396d
2 files changed
+56
-17
No files matched your search
@@ -86,3 +86,52 @@ def setup_text_tab_with_refresh(
|
||||
|
||||
ttk.Button(top, text="刷新", command=refresh).pack(side=LEFT)
|
||||
return refresh
|
||||
|
||||
|
||||
def setup_actions_log_tab(
|
||||
actions_log_tab: tk.Misc,
|
||||
*,
|
||||
ScrolledText_cls: Any,
|
||||
theme_getter: Callable[[], str],
|
||||
) -> Callable[[], None]:
|
||||
"""构建行为日志 Tab(simple text + 工具栏),返回 ``refresh_actions_log``。"""
|
||||
from gui.components.actions_log_toolbar import setup_actions_log_toolbar
|
||||
|
||||
actions_log_top, actions_log_text = setup_simple_text_tab(
|
||||
actions_log_tab, ScrolledText_cls=ScrolledText_cls,
|
||||
)
|
||||
handles = setup_actions_log_toolbar(
|
||||
actions_log_top,
|
||||
actions_log_text=actions_log_text,
|
||||
theme_getter=theme_getter,
|
||||
)
|
||||
return handles.refresh_actions_log
|
||||
|
||||
|
||||
def setup_ocr_results_tab(
|
||||
ocr_results_tab: tk.Misc,
|
||||
*,
|
||||
ScrolledText_cls: Any,
|
||||
) -> Tuple[Callable[[Any], None], Callable[[], None]]:
|
||||
"""构建 OCR 结果 Tab,返回 ``(update_ocr_results, refresh_now)``。
|
||||
|
||||
- ``update_ocr_results(results)``: 由 do_screenshot 完成 OCR 后调用,刷新内容
|
||||
- ``refresh_now()``: 给"刷新"按钮(显示空内容)
|
||||
"""
|
||||
from gui.components.ocr_results_view import update_ocr_results as _update_ocr_results_impl
|
||||
|
||||
ocr_results_top, ocr_results_text = setup_simple_text_tab(
|
||||
ocr_results_tab, ScrolledText_cls=ScrolledText_cls,
|
||||
)
|
||||
|
||||
def update_ocr_results(results: Any) -> None:
|
||||
_update_ocr_results_impl(ocr_results_text, results)
|
||||
|
||||
def refresh_now() -> None:
|
||||
update_ocr_results([])
|
||||
|
||||
ttk.Button(ocr_results_top, text="刷新", command=refresh_now).pack(side=LEFT)
|
||||
ttk.Label(ocr_results_top, text='(点击"截图+OCR"按钮自动更新)').pack(
|
||||
side=LEFT, padx=(10, 0)
|
||||
)
|
||||
return update_ocr_results, refresh_now
|
||||
+7
-17
@@ -29,7 +29,6 @@ from gui.components.actions_log_view import (
|
||||
configure_actions_log_colors as _configure_actions_log_colors_impl,
|
||||
refresh_actions_log as _refresh_actions_log_impl,
|
||||
)
|
||||
from gui.components.ocr_results_view import update_ocr_results as _update_ocr_results_impl
|
||||
from gui.components.log_pump import pump_logs as _pump_logs_impl
|
||||
from gui.components.win_record_view import (
|
||||
WinRecordView as _WinRecordView,
|
||||
@@ -66,11 +65,12 @@ from gui.components.run_tab import setup_run_tab
|
||||
from gui.components.filter_tab import setup_filter_tab
|
||||
from gui.components.realtime_tab import setup_realtime_tab
|
||||
from gui.components.win_record_tab import setup_win_record_tab
|
||||
from gui.components.actions_log_toolbar import setup_actions_log_toolbar
|
||||
from gui.components.simple_tabs import (
|
||||
setup_simple_text_tab,
|
||||
setup_stats_tab,
|
||||
setup_text_tab_with_refresh,
|
||||
setup_actions_log_tab,
|
||||
setup_ocr_results_tab,
|
||||
)
|
||||
from gui.components.preview_tab import setup_preview_tab
|
||||
from gui.components.keywords_tab import setup_keywords_tab
|
||||
@@ -372,25 +372,15 @@ def main():
|
||||
)
|
||||
|
||||
# 行为日志显示(点击/识别/耗时)
|
||||
actions_log_top, actions_log_text = setup_simple_text_tab(actions_log_tab, ScrolledText_cls=ScrolledText)
|
||||
|
||||
_actions_log_handles = setup_actions_log_toolbar(
|
||||
actions_log_top,
|
||||
actions_log_text=actions_log_text,
|
||||
refresh_actions_log = setup_actions_log_tab(
|
||||
actions_log_tab,
|
||||
ScrolledText_cls=ScrolledText,
|
||||
theme_getter=lambda: str(gui_theme_var.get() or "litera"),
|
||||
)
|
||||
refresh_actions_log = _actions_log_handles.refresh_actions_log
|
||||
|
||||
# OCR结果显示
|
||||
ocr_results_top, ocr_results_text = setup_simple_text_tab(ocr_results_tab, ScrolledText_cls=ScrolledText)
|
||||
|
||||
def update_ocr_results(results):
|
||||
_update_ocr_results_impl(ocr_results_text, results)
|
||||
ttk.Button(
|
||||
ocr_results_top, text="刷新", command=lambda: update_ocr_results([])
|
||||
).pack(side=LEFT)
|
||||
ttk.Label(ocr_results_top, text='(点击"截图+OCR"按钮自动更新)').pack(
|
||||
side=LEFT, padx=(10, 0)
|
||||
update_ocr_results, _ = setup_ocr_results_tab(
|
||||
ocr_results_tab, ScrolledText_cls=ScrolledText,
|
||||
)
|
||||
|
||||
# 顶部常驻按钮(放在 image_var/update_ocr_results/refresh_preview 都已就绪之后)
|
||||
|
||||
Reference in new issue
Block a user