refactor(gui): reservation/high_value 用 setup_text_tab_with_refresh 复用 (452 → 450)

This commit is contained in:
Your Name committed 2026-05-30 18:37:12 +08:00
1 parent f75d3ae368
commit a6648c5ce8
2 files changed
+33 -15

No files matched your search

+20
View File
@@ -66,3 +66,23 @@ def setup_stats_tab(
ttk.Button(stats_top, text="刷新", command=refresh_stats).pack(side=LEFT)
return refresh_stats
def setup_text_tab_with_refresh(
tab: tk.Misc,
*,
refresh_impl: Callable[[tk.Text], None],
ScrolledText_cls: Any,
) -> Callable[[], None]:
"""``setup_simple_text_tab`` + 一个绑定到刷新按钮的 ``refresh_impl(text)`` 回调。
用于 reservation / high_value / ocr_results 等"刷新按钮 → 把内容写入 text"的简单 Tab。
返回零参数的 ``refresh()`` 给调用方调度。
"""
top, text = setup_simple_text_tab(tab, ScrolledText_cls=ScrolledText_cls)
def refresh() -> None:
refresh_impl(text)
ttk.Button(top, text="刷新", command=refresh).pack(side=LEFT)
return refresh
+13 -15
View File
@@ -67,7 +67,11 @@ 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
from gui.components.simple_tabs import (
setup_simple_text_tab,
setup_stats_tab,
setup_text_tab_with_refresh,
)
from gui.components.preview_tab import setup_preview_tab
from gui.components.keywords_tab import setup_keywords_tab
from gui.components.main_notebook import setup_main_notebook
@@ -354,23 +358,17 @@ def main():
refresh_stats = setup_stats_tab(stats_tab, runner=runner, ScrolledText_cls=ScrolledText)
# 预约队列显示
reservation_top, reservation_text = setup_simple_text_tab(reservation_tab, ScrolledText_cls=ScrolledText)
def refresh_reservations():
_refresh_reservations_impl(reservation_text)
ttk.Button(reservation_top, text="刷新", command=refresh_reservations).pack(
side=LEFT
refresh_reservations = setup_text_tab_with_refresh(
reservation_tab,
refresh_impl=_refresh_reservations_impl,
ScrolledText_cls=ScrolledText,
)
# 高价值房间显示
high_value_top, high_value_text = setup_simple_text_tab(high_value_tab, ScrolledText_cls=ScrolledText)
def refresh_high_value_rooms():
_refresh_high_value_rooms_impl(high_value_text)
ttk.Button(high_value_top, text="刷新", command=refresh_high_value_rooms).pack(
side=LEFT
refresh_high_value_rooms = setup_text_tab_with_refresh(
high_value_tab,
refresh_impl=_refresh_high_value_rooms_impl,
ScrolledText_cls=ScrolledText,
)
# 行为日志显示(点击/识别/耗时)