完成inject页面
This commit is contained in:
parent
1bb0a91d66
commit
e0ff6bc18e
|
@ -25,4 +25,8 @@ HomeWelcome = "欢迎使用 PEinjector"
|
||||||
HomeInfo = "一个增强 WindowsPE 的一个工具和平台\n点击下方版本号进行更新"
|
HomeInfo = "一个增强 WindowsPE 的一个工具和平台\n点击下方版本号进行更新"
|
||||||
InjectHead = "注入 ISO 镜像文件"
|
InjectHead = "注入 ISO 镜像文件"
|
||||||
Save = "保存"
|
Save = "保存"
|
||||||
DownloadImg = "查找 ISO"
|
DownloadImg = "下载 ISO"
|
||||||
|
CannotFindImg = "找不到镜像?"
|
||||||
|
CannotFindHelp = "找不到您的镜像文件可能是由于以下原因:\n1. 文件名中无 \"Win\"、\"PE\" 等关键字(不区分大小写)\n2. 镜像文件放置目录错误(若您更改了ventoy的配置文件)\n3. 镜像为 wim 映像(PEinjector及ventoy均不支持 .wim 文件的注入)"
|
||||||
|
FeedbackInfo = "injectorHub 发生错误,请到项目主页 \"工单\"(issues) 页面反馈(需包含日志文件,且请勿重新启动hub)"
|
||||||
|
FeedbackInfoSpecial = "injectorHub 发生运行时错误,请关闭hub,并到项目主页 \"工单\"(issues) 页面反馈(需包含日志文件,且请勿重新启动hub)"
|
||||||
|
|
|
@ -3,6 +3,7 @@ import json
|
||||||
from lib import vars
|
from lib import vars
|
||||||
from logger.logger import *
|
from logger.logger import *
|
||||||
|
|
||||||
|
PEINJECTOR_FILE = "/PEinjector/PEinjector.7z"
|
||||||
|
|
||||||
isolist = []
|
isolist = []
|
||||||
|
|
||||||
|
@ -77,3 +78,28 @@ def get_injected_iso():
|
||||||
return []
|
return []
|
||||||
else:
|
else:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
def save_imgs(choose_lst):
|
||||||
|
info("[sync_disk]save inject info")
|
||||||
|
now_lists = []
|
||||||
|
ventoy_cfg = {}
|
||||||
|
if os.path.exists(vars.DISKMOUNT+f"{os.sep}ventoy{os.sep}ventoy.json"):
|
||||||
|
with open(vars.DISKMOUNT+f"{os.sep}ventoy{os.sep}ventoy.json", "r") as file:
|
||||||
|
ventoy_cfg = json.load(file)
|
||||||
|
if "injection" in ventoy_cfg:
|
||||||
|
for i in ventoy_cfg["injection"]:
|
||||||
|
if ("image" not in i or "archive" not in i):
|
||||||
|
warn(f"[sync_disk]error ventoy config \"{repr(i)}\"")
|
||||||
|
continue
|
||||||
|
if ("PEinjector" in i["archive"]):
|
||||||
|
continue
|
||||||
|
if (i["image"] not in isolist):
|
||||||
|
continue
|
||||||
|
now_lists.append(
|
||||||
|
{"image": i["image"].replace("\\", "/"), "archive": PEINJECTOR_FILE})
|
||||||
|
ventoy_cfg["injection"] = now_lists + \
|
||||||
|
[{"image": i.replace(
|
||||||
|
"\\", "/"), "archive": PEINJECTOR_FILE} for i in choose_lst]
|
||||||
|
with open(vars.DISKMOUNT+f"{os.sep}ventoy{os.sep}ventoy.json", "w") as file:
|
||||||
|
json.dump(ventoy_cfg, file)
|
||||||
|
|
|
@ -7,6 +7,7 @@ from logger.logger import *
|
||||||
from lib import vars
|
from lib import vars
|
||||||
from lib import sync_disk
|
from lib import sync_disk
|
||||||
from tkinter import Label as tkLabel
|
from tkinter import Label as tkLabel
|
||||||
|
from tkinter import messagebox
|
||||||
|
|
||||||
now_frame = None
|
now_frame = None
|
||||||
master: mtk.Frame = None
|
master: mtk.Frame = None
|
||||||
|
@ -42,12 +43,19 @@ def show_inject_page():
|
||||||
menuobjs.addmenu("iTellYou", lambda *args: __import__("webbrowser").open(
|
menuobjs.addmenu("iTellYou", lambda *args: __import__("webbrowser").open(
|
||||||
"https://next.itellyou.cn//"))
|
"https://next.itellyou.cn//"))
|
||||||
mtk.Menu(obj.root, w=200, h=400, x=posx, y=posy, menuobj=menuobjs)
|
mtk.Menu(obj.root, w=200, h=400, x=posx, y=posy, menuobj=menuobjs)
|
||||||
|
|
||||||
|
def show_help_page(obj):
|
||||||
|
messagebox.showinfo("Injector Hub",
|
||||||
|
l("CannotFindHelp"))
|
||||||
|
|
||||||
action_btn_frame = mtk.Frame(inject_page)
|
action_btn_frame = mtk.Frame(inject_page)
|
||||||
mtk.Frame(action_btn_frame, w=10).pack(expand=True, side="left")
|
mtk.Frame(action_btn_frame, w=10).pack(expand=True, side="left")
|
||||||
savebtn = mtk.ButtonFill(action_btn_frame, text=l("Save"))
|
savebtn = mtk.ButtonFill(action_btn_frame, text=l("Save"))
|
||||||
savebtn.pack(side="left")
|
savebtn.pack(side="left")
|
||||||
mtk.Button(action_btn_frame, text=l("DownloadImg"),
|
mtk.Button(action_btn_frame, text=l("DownloadImg"),
|
||||||
func=show_download_list).pack(side="left")
|
func=show_download_list).pack(side="left")
|
||||||
|
mtk.ButtonLight(action_btn_frame, text=l("CannotFindImg"),
|
||||||
|
func=show_help_page, color_type="info", w=120).pack(side="left")
|
||||||
mtk.Frame(action_btn_frame, w=10000).pack(
|
mtk.Frame(action_btn_frame, w=10000).pack(
|
||||||
fill="x", expand=True, side="left")
|
fill="x", expand=True, side="left")
|
||||||
|
|
||||||
|
@ -112,6 +120,14 @@ def show_inject_page():
|
||||||
|
|
||||||
updatelist()
|
updatelist()
|
||||||
|
|
||||||
|
def save_cfg(obj):
|
||||||
|
choose_lst = []
|
||||||
|
for i in range(len(checkboxlist)):
|
||||||
|
if (checkboxlist[i].ishover == 1):
|
||||||
|
choose_lst.append(img_list[i])
|
||||||
|
sync_disk.save_imgs(choose_lst)
|
||||||
|
savebtn._func = save_cfg
|
||||||
|
|
||||||
inject_page.pack(anchor="nw", side="top")
|
inject_page.pack(anchor="nw", side="top")
|
||||||
now_frame = inject_page
|
now_frame = inject_page
|
||||||
|
|
||||||
|
|
20
ui/nav.py
20
ui/nav.py
|
@ -1,16 +1,35 @@
|
||||||
|
import time
|
||||||
from magictk import mtk, color_tmpl
|
from magictk import mtk, color_tmpl
|
||||||
from logger.logger import *
|
from logger.logger import *
|
||||||
|
|
||||||
|
|
||||||
choose_id = 0
|
choose_id = 0
|
||||||
|
|
||||||
|
load_lock = False
|
||||||
|
load_timer = 0
|
||||||
|
anim_added = False
|
||||||
|
|
||||||
|
|
||||||
def nav_callback(obj):
|
def nav_callback(obj):
|
||||||
|
global load_lock, load_timer, anim_added
|
||||||
ids = obj.ids
|
ids = obj.ids
|
||||||
side = navlists[ids]["side"]
|
side = navlists[ids]["side"]
|
||||||
global choose_id, nav_main, lastobj
|
global choose_id, nav_main, lastobj
|
||||||
if (choose_id == ids):
|
if (choose_id == ids):
|
||||||
return
|
return
|
||||||
|
if (load_lock == True):
|
||||||
|
return
|
||||||
|
load_timer = 5 # 再小就会出bug
|
||||||
|
load_lock = True
|
||||||
|
if (anim_added == False):
|
||||||
|
def anim_func(*args):
|
||||||
|
global load_lock, load_timer
|
||||||
|
if (load_timer > 0):
|
||||||
|
load_timer -= 1
|
||||||
|
if (load_timer == 0 and load_lock == True):
|
||||||
|
load_lock = False
|
||||||
|
nav_frame_now.root.anim.append(anim_func)
|
||||||
|
anim_added = True
|
||||||
choose_id = ids
|
choose_id = ids
|
||||||
if (side == "top"):
|
if (side == "top"):
|
||||||
nav_frame_now.place_forget()
|
nav_frame_now.place_forget()
|
||||||
|
@ -21,6 +40,7 @@ def nav_callback(obj):
|
||||||
|
|
||||||
lastobj.pack_forget()
|
lastobj.pack_forget()
|
||||||
lastobj = btn_frame_list[choose_id](nav_main)
|
lastobj = btn_frame_list[choose_id](nav_main)
|
||||||
|
nav_frame_now.root.main_tk.update()
|
||||||
|
|
||||||
|
|
||||||
def pack_nav(master: mtk.Frame, root: mtk.Frame, navlist: list):
|
def pack_nav(master: mtk.Frame, root: mtk.Frame, navlist: list):
|
||||||
|
|
21
ui/win.py
21
ui/win.py
|
@ -174,6 +174,24 @@ def main():
|
||||||
mtk.load_icon_pack("res/icon.pack")
|
mtk.load_icon_pack("res/icon.pack")
|
||||||
main_win = mtk.Tk(title="Injector Hub", w=1000, h=800)
|
main_win = mtk.Tk(title="Injector Hub", w=1000, h=800)
|
||||||
|
|
||||||
|
def exp_callback(*args):
|
||||||
|
err("[errtrace]caught err from tkinter:"+repr(args[1]))
|
||||||
|
for i in [i.replace("\n", "")
|
||||||
|
for i in traceback.format_exception(args[0], args[1], args[2])]:
|
||||||
|
firstlen_flag = "* "
|
||||||
|
lastlen = ""
|
||||||
|
for j in textwrap.wrap(i, width=40):
|
||||||
|
err("[errtrace]"+" "+firstlen_flag+" " *
|
||||||
|
(len(lastlen)-len(lastlen.lstrip()))+j)
|
||||||
|
lastlen = " " * (len(lastlen)-len(lastlen.lstrip()))+j
|
||||||
|
firstlen_flag = " "
|
||||||
|
if (DEBUG == 1):
|
||||||
|
raise
|
||||||
|
else:
|
||||||
|
messagebox.showerror("Injector Hub Error",
|
||||||
|
l("FeedbackInfoSpecial"))
|
||||||
|
main_win.main_tk.report_callback_exception = exp_callback
|
||||||
|
|
||||||
main_frame = mtk.Frame(main_win, w=10000)
|
main_frame = mtk.Frame(main_win, w=10000)
|
||||||
nav.pack_nav(main_win, main_frame, nav_list)
|
nav.pack_nav(main_win, main_frame, nav_list)
|
||||||
main_frame.pack(side="left", fill="both", expand=True)
|
main_frame.pack(side="left", fill="both", expand=True)
|
||||||
|
@ -197,3 +215,6 @@ def run():
|
||||||
firstlen_flag = " "
|
firstlen_flag = " "
|
||||||
if (DEBUG == 1):
|
if (DEBUG == 1):
|
||||||
raise
|
raise
|
||||||
|
else:
|
||||||
|
messagebox.showerror("Injector Hub Error",
|
||||||
|
l("FeedbackInfo"))
|
||||||
|
|
Loading…
Reference in New Issue