refactor(gui): 抽 filter_tab UI 创建到 components/filter_tab (2122 → 2037)
This commit is contained in:
1 parent
6c7bbf0945
commit
e784efd5f8
2 files changed
+129
-99
No files matched your search
@@ -0,0 +1,115 @@
|
||||
"""筛选设置 Tab UI 创建逻辑(9 个 var)。
|
||||
|
||||
从 ``gui/gui_app.py`` 抽出。原本是 ``main()`` 内长 100 行的 widget 创建段。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import tkinter as tk
|
||||
from tkinter import ttk
|
||||
from tkinter.constants import LEFT, X
|
||||
from typing import Dict
|
||||
|
||||
|
||||
def setup_filter_tab(parent: ttk.Notebook, *, vars_: Dict[str, tk.Variable]) -> ttk.Frame:
|
||||
filter_tab = ttk.Frame(parent)
|
||||
parent.add(filter_tab, text="筛选设置")
|
||||
|
||||
cfg_box = ttk.LabelFrame(filter_tab, text="福袋筛选条件")
|
||||
cfg_box.pack(fill=X, padx=10, pady=(10, 10))
|
||||
|
||||
row = ttk.Frame(cfg_box)
|
||||
row.pack(fill=X, padx=10, pady=(10, 8))
|
||||
ttk.Label(row, text="最低价值(元):").pack(side=LEFT)
|
||||
ttk.Spinbox(
|
||||
row,
|
||||
from_=0,
|
||||
to=99999,
|
||||
increment=0.01,
|
||||
format="%.2f",
|
||||
textvariable=vars_["min_value_var"],
|
||||
width=10,
|
||||
).pack(side=LEFT)
|
||||
|
||||
rowp = ttk.Frame(cfg_box)
|
||||
rowp.pack(fill=X, padx=10, pady=(0, 8))
|
||||
ttk.Label(rowp, text="参与人数范围:").pack(side=LEFT)
|
||||
ttk.Spinbox(
|
||||
rowp,
|
||||
from_=0,
|
||||
to=99999999,
|
||||
increment=1,
|
||||
textvariable=vars_["min_participants_var"],
|
||||
width=10,
|
||||
).pack(side=LEFT)
|
||||
ttk.Label(rowp, text=" ~ ").pack(side=LEFT)
|
||||
ttk.Spinbox(
|
||||
rowp,
|
||||
from_=0,
|
||||
to=99999999,
|
||||
increment=1,
|
||||
textvariable=vars_["max_participants_var"],
|
||||
width=10,
|
||||
).pack(side=LEFT)
|
||||
ttk.Label(rowp, text="(填0表示不限制)").pack(side=LEFT)
|
||||
|
||||
row2 = ttk.Frame(cfg_box)
|
||||
row2.pack(fill=X, padx=10, pady=(0, 8))
|
||||
ttk.Label(row2, text="倒计时小于(秒)时不参与:").pack(side=LEFT)
|
||||
ttk.Spinbox(
|
||||
row2, from_=0, to=300, increment=1, textvariable=vars_["skip_lt_seconds_var"], width=6
|
||||
).pack(side=LEFT)
|
||||
ttk.Label(row2, text="(剩余时间太短,不参与)").pack(side=LEFT, padx=(6, 0))
|
||||
|
||||
row3 = ttk.Frame(cfg_box)
|
||||
row3.pack(fill=X, padx=10, pady=(0, 8))
|
||||
ttk.Checkbutton(
|
||||
row3, text="自动加入粉丝团(谨慎:可能消耗钻石)", variable=vars_["auto_join_var"]
|
||||
).pack(side=LEFT)
|
||||
|
||||
row4 = ttk.Frame(cfg_box)
|
||||
row4.pack(fill=X, padx=10, pady=(0, 10))
|
||||
ttk.Label(row4, text="粉丝团失败策略:").pack(side=LEFT)
|
||||
ttk.Combobox(
|
||||
row4,
|
||||
textvariable=vars_["fansclub_action_var"],
|
||||
values=["stay", "switch"],
|
||||
width=10,
|
||||
state="readonly",
|
||||
).pack(side=LEFT)
|
||||
ttk.Label(row4, text="(stay=停留,switch=切换直播间)").pack(
|
||||
side=LEFT, padx=(6, 0)
|
||||
)
|
||||
# 粉丝团等待/点击延迟设置
|
||||
row4b = ttk.Frame(cfg_box)
|
||||
row4b.pack(fill=X, padx=10, pady=(0, 8))
|
||||
ttk.Label(row4b, text="粉丝团点击延迟(s):").pack(side=LEFT)
|
||||
ttk.Spinbox(
|
||||
row4b,
|
||||
from_=0.1,
|
||||
to=5.0,
|
||||
increment=0.1,
|
||||
textvariable=vars_["fansclub_click_delay_var"],
|
||||
width=6,
|
||||
).pack(side=LEFT, padx=(6, 12))
|
||||
ttk.Label(row4b, text="自动加入等待(s):").pack(side=LEFT)
|
||||
ttk.Spinbox(
|
||||
row4b,
|
||||
from_=0.5,
|
||||
to=10.0,
|
||||
increment=0.5,
|
||||
textvariable=vars_["fansclub_auto_wait_var"],
|
||||
width=6,
|
||||
).pack(side=LEFT, padx=(6, 12))
|
||||
ttk.Label(row4b, text="手动加入等待(s):").pack(side=LEFT)
|
||||
ttk.Spinbox(
|
||||
row4b,
|
||||
from_=0.5,
|
||||
to=10.0,
|
||||
increment=0.5,
|
||||
textvariable=vars_["fansclub_manual_wait_var"],
|
||||
width=6,
|
||||
).pack(side=LEFT, padx=(6, 0))
|
||||
|
||||
# 标签页3:高价值预约
|
||||
return filter_tab
|
||||
+14
-99
@@ -92,6 +92,7 @@ from gui.components.logging_tab import setup_logging_tab
|
||||
from gui.components.yanghao_tab import setup_yanghao_tab
|
||||
from gui.components.reservation_tab import setup_reservation_tab
|
||||
from gui.components.run_tab import setup_run_tab
|
||||
from gui.components.filter_tab import setup_filter_tab
|
||||
|
||||
# 导入日志颜色配置模块
|
||||
try:
|
||||
@@ -781,106 +782,20 @@ def main():
|
||||
},
|
||||
)
|
||||
# 标签页2:筛选设置
|
||||
filter_tab = ttk.Frame(left_notebook)
|
||||
left_notebook.add(filter_tab, text="筛选设置")
|
||||
|
||||
cfg_box = ttk.LabelFrame(filter_tab, text="福袋筛选条件")
|
||||
cfg_box.pack(fill=X, padx=10, pady=(10, 10))
|
||||
|
||||
row = ttk.Frame(cfg_box)
|
||||
row.pack(fill=X, padx=10, pady=(10, 8))
|
||||
ttk.Label(row, text="最低价值(元):").pack(side=LEFT)
|
||||
ttk.Spinbox(
|
||||
row,
|
||||
from_=0,
|
||||
to=99999,
|
||||
increment=0.01,
|
||||
format="%.2f",
|
||||
textvariable=min_value_var,
|
||||
width=10,
|
||||
).pack(side=LEFT)
|
||||
|
||||
rowp = ttk.Frame(cfg_box)
|
||||
rowp.pack(fill=X, padx=10, pady=(0, 8))
|
||||
ttk.Label(rowp, text="参与人数范围:").pack(side=LEFT)
|
||||
ttk.Spinbox(
|
||||
rowp,
|
||||
from_=0,
|
||||
to=99999999,
|
||||
increment=1,
|
||||
textvariable=min_participants_var,
|
||||
width=10,
|
||||
).pack(side=LEFT)
|
||||
ttk.Label(rowp, text=" ~ ").pack(side=LEFT)
|
||||
ttk.Spinbox(
|
||||
rowp,
|
||||
from_=0,
|
||||
to=99999999,
|
||||
increment=1,
|
||||
textvariable=max_participants_var,
|
||||
width=10,
|
||||
).pack(side=LEFT)
|
||||
ttk.Label(rowp, text="(填0表示不限制)").pack(side=LEFT)
|
||||
|
||||
row2 = ttk.Frame(cfg_box)
|
||||
row2.pack(fill=X, padx=10, pady=(0, 8))
|
||||
ttk.Label(row2, text="倒计时小于(秒)时不参与:").pack(side=LEFT)
|
||||
ttk.Spinbox(
|
||||
row2, from_=0, to=300, increment=1, textvariable=skip_lt_seconds_var, width=6
|
||||
).pack(side=LEFT)
|
||||
ttk.Label(row2, text="(剩余时间太短,不参与)").pack(side=LEFT, padx=(6, 0))
|
||||
|
||||
row3 = ttk.Frame(cfg_box)
|
||||
row3.pack(fill=X, padx=10, pady=(0, 8))
|
||||
ttk.Checkbutton(
|
||||
row3, text="自动加入粉丝团(谨慎:可能消耗钻石)", variable=auto_join_var
|
||||
).pack(side=LEFT)
|
||||
|
||||
row4 = ttk.Frame(cfg_box)
|
||||
row4.pack(fill=X, padx=10, pady=(0, 10))
|
||||
ttk.Label(row4, text="粉丝团失败策略:").pack(side=LEFT)
|
||||
ttk.Combobox(
|
||||
row4,
|
||||
textvariable=fansclub_action_var,
|
||||
values=["stay", "switch"],
|
||||
width=10,
|
||||
state="readonly",
|
||||
).pack(side=LEFT)
|
||||
ttk.Label(row4, text="(stay=停留,switch=切换直播间)").pack(
|
||||
side=LEFT, padx=(6, 0)
|
||||
setup_filter_tab(
|
||||
left_notebook,
|
||||
vars_={
|
||||
"auto_join_var": auto_join_var,
|
||||
"fansclub_action_var": fansclub_action_var,
|
||||
"fansclub_auto_wait_var": fansclub_auto_wait_var,
|
||||
"fansclub_click_delay_var": fansclub_click_delay_var,
|
||||
"fansclub_manual_wait_var": fansclub_manual_wait_var,
|
||||
"max_participants_var": max_participants_var,
|
||||
"min_participants_var": min_participants_var,
|
||||
"min_value_var": min_value_var,
|
||||
"skip_lt_seconds_var": skip_lt_seconds_var,
|
||||
},
|
||||
)
|
||||
# 粉丝团等待/点击延迟设置
|
||||
row4b = ttk.Frame(cfg_box)
|
||||
row4b.pack(fill=X, padx=10, pady=(0, 8))
|
||||
ttk.Label(row4b, text="粉丝团点击延迟(s):").pack(side=LEFT)
|
||||
ttk.Spinbox(
|
||||
row4b,
|
||||
from_=0.1,
|
||||
to=5.0,
|
||||
increment=0.1,
|
||||
textvariable=fansclub_click_delay_var,
|
||||
width=6,
|
||||
).pack(side=LEFT, padx=(6, 12))
|
||||
ttk.Label(row4b, text="自动加入等待(s):").pack(side=LEFT)
|
||||
ttk.Spinbox(
|
||||
row4b,
|
||||
from_=0.5,
|
||||
to=10.0,
|
||||
increment=0.5,
|
||||
textvariable=fansclub_auto_wait_var,
|
||||
width=6,
|
||||
).pack(side=LEFT, padx=(6, 12))
|
||||
ttk.Label(row4b, text="手动加入等待(s):").pack(side=LEFT)
|
||||
ttk.Spinbox(
|
||||
row4b,
|
||||
from_=0.5,
|
||||
to=10.0,
|
||||
increment=0.5,
|
||||
textvariable=fansclub_manual_wait_var,
|
||||
width=6,
|
||||
).pack(side=LEFT, padx=(6, 0))
|
||||
|
||||
# 标签页3:高价值预约
|
||||
setup_reservation_tab(
|
||||
left_notebook,
|
||||
vars_={
|
||||
|
||||
Reference in new issue
Block a user