update
This commit is contained in:
@@ -22,8 +22,14 @@ class MainEntry:
|
||||
self.icon = None
|
||||
# 非 macOS 使用系统托盘(pystray);macOS 使用原生菜单栏
|
||||
self.systray_supported = sys.platform != "darwin"
|
||||
|
||||
# 主内容容器
|
||||
self.main_frame = tk.Frame(self.master, bg="#f0f0f0")
|
||||
self.main_frame.pack(fill=tk.BOTH, expand=True, padx=20, pady=20)
|
||||
|
||||
# 首次进入根据平台构建菜单
|
||||
self.create_menu()
|
||||
self.create_dashboard()
|
||||
|
||||
def build_menu_model(self):
|
||||
# 菜单模型统一描述所有菜单:
|
||||
@@ -65,6 +71,29 @@ class MainEntry:
|
||||
},
|
||||
]
|
||||
|
||||
def create_dashboard(self):
|
||||
# 根据菜单模型构建主窗口按钮面板
|
||||
for widget in self.main_frame.winfo_children():
|
||||
widget.destroy()
|
||||
|
||||
model = self.build_menu_model()
|
||||
|
||||
for group in model:
|
||||
# 为每个分组创建 LabelFrame
|
||||
group_frame = tk.LabelFrame(self.main_frame, text=group["label"], bg="#f0f0f0", padx=10, pady=10)
|
||||
group_frame.pack(fill=tk.X, pady=10, padx=10)
|
||||
|
||||
for it in group["items"]:
|
||||
if it.get("separator"):
|
||||
continue
|
||||
|
||||
fn = getattr(self, it["action"]) if it.get("action") else None
|
||||
state = tk.NORMAL if it.get("enabled", True) else tk.DISABLED
|
||||
|
||||
# 创建按钮
|
||||
btn = tk.Button(group_frame, text=it["label"], command=fn, state=state)
|
||||
btn.pack(side=tk.LEFT, padx=5)
|
||||
|
||||
def create_menu(self):
|
||||
# 根据统一菜单模型与平台类型,渲染到系统托盘或 Tk 菜单栏
|
||||
model = self.build_menu_model()
|
||||
@@ -119,6 +148,7 @@ class MainEntry:
|
||||
self.qmt_enabled = True
|
||||
PrintLog(LogLevel.INFO, "QMT 市场数据已开启")
|
||||
self.create_menu()
|
||||
self.create_dashboard()
|
||||
|
||||
def handler(self):
|
||||
# 通用占位处理:当前仅记录点击行为,后续可替换为具体业务逻辑
|
||||
|
||||
Reference in New Issue
Block a user