2024-05-04 22:28:55 +08:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
from magictk import mtk, color_tmpl
|
|
|
|
from magictk import fontconfig
|
|
|
|
from ui.lang import l
|
|
|
|
from logger.logger import *
|
|
|
|
from lib import vars
|
2024-05-09 22:30:35 +08:00
|
|
|
from lib import sync_disk
|
2024-05-04 22:28:55 +08:00
|
|
|
from tkinter import Label as tkLabel
|
|
|
|
|
|
|
|
now_frame = None
|
|
|
|
master: mtk.Frame = None
|
2024-05-09 22:30:35 +08:00
|
|
|
checkboxlist = []
|
|
|
|
img_list = []
|
|
|
|
iso_frame = None
|
2024-05-04 22:28:55 +08:00
|
|
|
|
|
|
|
|
|
|
|
def show_inject_page():
|
2024-05-09 22:30:35 +08:00
|
|
|
global now_frame, master, checkboxlist
|
2024-05-04 22:28:55 +08:00
|
|
|
inject_page = mtk.Frame(master)
|
2024-05-09 22:30:35 +08:00
|
|
|
mtk.Frame(inject_page, w=10000, height=8).pack(fill="x", expand=True)
|
|
|
|
head_frame = mtk.Frame(inject_page)
|
|
|
|
mtk.Frame(head_frame, w=10).pack(
|
|
|
|
side="left", fill="y", expand=True)
|
|
|
|
mtk.Frame(inject_page, height=8).pack(fill="x", expand=True, side="left")
|
|
|
|
|
|
|
|
def show_download_list(obj):
|
|
|
|
posx = obj.root.main_tk.winfo_pointerx()-10
|
|
|
|
posy = obj.root.main_tk.winfo_pointery()-10
|
|
|
|
menuobjs = mtk.MenuObjs()
|
|
|
|
menuobjs.addmenu("-- Do not support WIM!--", lambda *args: True)
|
|
|
|
menuobjs.addmenu("WePE(stable)", lambda *args: __import__("webbrowser").open(
|
|
|
|
"https://www.wepe.com.cn/"))
|
|
|
|
menuobjs.addmenu("EdgelessPE(thanks)", lambda *args: __import__("webbrowser").open(
|
|
|
|
"https://home.edgeless.top/"))
|
|
|
|
menuobjs.addmenu("FirPE(unstable)", lambda *args: __import__("webbrowser").open(
|
|
|
|
"https://www.firpe.cn/"))
|
|
|
|
menuobjs.addmenu("HotPE(unstable)", lambda *args: __import__("webbrowser").open(
|
|
|
|
"https://www.hotpe.top/"))
|
|
|
|
menuobjs.addmenu("MicrosoftDoc", lambda *args: __import__("webbrowser").open(
|
|
|
|
"https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/download-winpe--windows-pe?view=windows-11"))
|
|
|
|
menuobjs.addmenu("iTellYou", lambda *args: __import__("webbrowser").open(
|
|
|
|
"https://next.itellyou.cn//"))
|
|
|
|
mtk.Menu(obj.root, w=200, h=400, x=posx, y=posy, menuobj=menuobjs)
|
|
|
|
action_btn_frame = mtk.Frame(inject_page)
|
|
|
|
mtk.Frame(action_btn_frame, w=10).pack(expand=True, side="left")
|
|
|
|
savebtn = mtk.ButtonFill(action_btn_frame, text=l("Save"))
|
|
|
|
savebtn.pack(side="left")
|
|
|
|
mtk.Button(action_btn_frame, text=l("DownloadImg"),
|
|
|
|
func=show_download_list).pack(side="left")
|
|
|
|
mtk.Frame(action_btn_frame, w=10000).pack(
|
|
|
|
fill="x", expand=True, side="left")
|
|
|
|
|
|
|
|
mtk.Frame(inject_page, height=16).pack(fill="x", expand=True, side="left")
|
|
|
|
head_label = tkLabel(
|
|
|
|
head_frame,
|
|
|
|
width=10000,
|
|
|
|
text=l("InjectHead"),
|
|
|
|
background=color_tmpl.default_color["background"],
|
|
|
|
foreground=color_tmpl.default_color["primary_text"],
|
|
|
|
font=(fontconfig.getfont(), 14),
|
|
|
|
anchor='w'
|
|
|
|
)
|
|
|
|
head_label.pack(side="left", anchor='w')
|
|
|
|
head_frame.pack(fill="x", expand=True, anchor='w')
|
|
|
|
|
|
|
|
action_btn_frame.pack(fill="x", expand=True)
|
|
|
|
|
|
|
|
show_all_img = vars.SHOWALLIMAGE
|
|
|
|
|
|
|
|
def updatelist():
|
|
|
|
global checkboxlist, iso_frame, img_list
|
|
|
|
if (iso_frame is not None):
|
|
|
|
iso_frame.destroy() # 避免内存泄漏
|
|
|
|
del iso_frame
|
|
|
|
iso_frame = None
|
|
|
|
isolists = sync_disk.get_isolist()
|
|
|
|
imgsums = 0
|
|
|
|
for isopath in isolists:
|
|
|
|
if show_all_img or ('pe' in isopath.lower() or 'win' in isopath.lower()):
|
|
|
|
imgsums += 1
|
|
|
|
|
|
|
|
container_frame = mtk.Frame(inject_page)
|
|
|
|
mtk.Frame(container_frame, w=10).pack(expand=True, side="left")
|
|
|
|
iso_frame = mtk.Container(container_frame, w=10000, h=10000,
|
|
|
|
container_h=imgsums*20)
|
|
|
|
if (len(checkboxlist) > 0):
|
|
|
|
for i in checkboxlist:
|
|
|
|
i.canvas.destroy() # 避免内存泄漏
|
|
|
|
del i
|
|
|
|
checkboxlist = []
|
|
|
|
img_list = []
|
|
|
|
|
|
|
|
for isopath in isolists:
|
|
|
|
if show_all_img or ('pe' in isopath.lower() or 'win' in isopath.lower()):
|
|
|
|
isoname = isopath.split(os.sep)[-1]
|
|
|
|
if (len(isoname) > 40):
|
|
|
|
isoname = isoname[:37]+"..."
|
|
|
|
checkboxlist.append(mtk.Checkbox(
|
|
|
|
iso_frame, text=isoname, h=20, w=400))
|
|
|
|
img_list.append(isopath)
|
|
|
|
checkboxlist[-1].pack(fill="x", expand=True)
|
|
|
|
|
|
|
|
for injectedpath in sync_disk.get_injected_iso():
|
|
|
|
checkobj = checkboxlist[img_list.index(injectedpath)]
|
|
|
|
checkobj.ishover = 1
|
|
|
|
checkobj._update_color()
|
|
|
|
|
|
|
|
iso_frame.pack(fill="x", expand=True, side="left")
|
|
|
|
mtk.Frame(container_frame, w=20).pack(side="left")
|
|
|
|
container_frame.pack(fill="both", expand=True)
|
|
|
|
|
|
|
|
updatelist()
|
|
|
|
|
|
|
|
inject_page.pack(anchor="nw", side="top")
|
2024-05-04 22:28:55 +08:00
|
|
|
now_frame = inject_page
|
|
|
|
|
|
|
|
|
|
|
|
def inject_ui(root: mtk.Frame):
|
|
|
|
global master
|
|
|
|
inject_root_frame = mtk.Frame(root)
|
|
|
|
master = inject_root_frame
|
|
|
|
show_inject_page()
|
|
|
|
inject_root_frame.pack(fill="both", expand=True)
|
|
|
|
return inject_root_frame
|