from magictk import mtk, color_tmpl from logger.logger import * choose_id = 0 def nav_callback(obj): ids = obj.ids side = navlists[ids]["side"] global choose_id if (choose_id == ids): return choose_id = ids if (side == "top"): nav_frame_now.place_forget() nav_frame_now.place(x=0, y=50*ids, width=3, height=50, anchor='nw') else: nav_frame_now.place_forget() nav_frame_now.place(x=0, rely=1, width=3, height=50, anchor='sw') def pack_nav(master: mtk.Frame, root: mtk.Frame, navlist: list): global nav_frame_now, btn_list, navlists, nav_main, btn_frame_list navlists = navlist nav_frame = mtk.Frame(master) nav_frame_show = mtk.Frame(nav_frame, w=3) nav_frame_now = mtk.Frame( nav_frame_show, w=3, bg=color_tmpl.default_color["primary"]) nav_frame_now.place(x=0, y=0, width=3, height=50) nav_frame_show.pack(side="left", fill='y') mtk.Frame(nav_frame, w=1).pack( side="left", expand=True, fill='y') nav_frame_main = mtk.Frame(nav_frame, w=50) btn_list = [] btn_frame_list = [] ids = 0 for i in navlist: icon = i["icon"] frame = i["frame"] side = i["side"] btn_list.append(mtk.ButtonLight( master=nav_frame_main, color_type="plain", iconname=icon, iconsize=32, w=50, h=50, func=nav_callback)) btn_list[-1].ids = ids btn_list[-1].pack(side=side) btn_frame_list.append(frame) ids += 1 nav_frame_main.pack(side="left", fill='both') mtk.Frame(nav_frame, w=2).pack( side="left", expand=True, fill='y') mtk.Frame(nav_frame, w=1, bg=color_tmpl.default_color["border_light"]).pack( side="left", expand=True, fill='y') nav_frame.pack(side="left", expand=True, fill='y') nav_main = mtk.Frame( master, w=1000) btn_frame_list[0](nav_main) nav_main.pack(side="right", fill='both')