from tkinter import messagebox from magictk import mtk from logger.logger import * from ui import nav from ui import installer from lib import get_disk from ui.lang import load_lang, l import sys import getpass import platform import ctypes init() load_lang("zh_cn") # TODO:读取设置 disk_res = get_disk.find_hub_disk() errno = disk_res[0] root_disk = disk_res[1] if (errno == 1): messagebox.showerror("Injector Hub Error", root_disk) sys.exit(1) elif (errno == 2): info("[win]cannot find installed disk") if (platform.system() == "Linux" and getpass.getuser() != "root"): messagebox.showerror("Injector Hub Error", l("PermissionDeniedLinux")) sys.exit(1) if (platform.system() == "Windows" and ctypes.windll.shell32.IsUserAnAdmin() == False): messagebox.showerror("Injector Hub Error", l("PermissionDeniedWin")) nav_list = [ {"icon": "lightning", "frame": installer.installer_ui, "side": "top"} ] else: info(f"[win]found installed disk \"{root_disk}\"") nav_list = [ {"icon": "home-filled", "frame": None, "side": "top"}, {"icon": "dvd", "frame": None, "side": "top"}, {"icon": "plugin", "frame": None, "side": "top"}, {"icon": "setting", "frame": None, "side": "bottom"} ] info("[win]init window") mtk.load_icon_pack("res/icon.pack") main_win = mtk.Tk(title="Injector Hub", w=1000, h=800) main_frame = mtk.Frame(main_win, w=10000) nav.pack_nav(main_win, main_frame, nav_list) main_frame.pack(side="left", fill="both", expand=True) def main(): info("[win]mainloop") main_win.mainloop()