injectorHub/ui/homeui.py

67 lines
2.6 KiB
Python
Raw Normal View History

2024-05-04 21:27:20 +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
from tkinter import Label as tkLabel
now_frame = None
master: mtk.Frame = None
def show_home_page():
global now_frame, master
first_page = mtk.Frame(master)
mtk.Frame(first_page, w=10000).pack(fill="both", expand=True)
smileimg = mtk.PhotoImage(file="res"+os.sep+"smile.gif")
frames = mtk.Frame(first_page)
smilelabel = tkLabel(frames, image=smileimg,
background=color_tmpl.default_color["background"])
smilelabel.pack()
smilelabel.image = smileimg
frames.pack(fill='x')
mtk.Frame(first_page, w=10000, height=40).pack(fill="x")
mtk.Label(first_page, text=l("HomeWelcome"),
anchor='center', font=(fontconfig.getfont(), 20), background=color_tmpl.default_color["background"], foreground=color_tmpl.default_color["primary_text"]).pack(fill='x')
mtk.Label(first_page, text="\n"+l("HomeInfo"),
anchor='center', font=(fontconfig.getfont(), 10), background=color_tmpl.default_color["background"], foreground=color_tmpl.default_color["secondary_text"]).pack(fill='x')
mtk.Frame(first_page, height=30).pack()
buttonlist = mtk.Frame(first_page)
with open(vars.DISKMOUNT+os.sep+"PEinjector"+os.sep+"VERSION", 'r') as file:
version = file.read().replace("\n", "")
with open("VERSION", 'r') as file:
hubversion = file.read().replace("\n", "")
def restart_to_update(*args):
warn("[homeui]start update, exit")
python_path = sys.executable
os.execl(python_path, python_path, __file__.replace(
"ui"+os.sep+"homeui.py", "main.py"), "--upgrade", "--dis-permission-error")
def open_update(*args):
info("[homeui]open in webbrowser")
__import__("webbrowser").open(
"http://git.hmtsai.cn/cxykevin/injectorHub")
mtk.Frame(buttonlist, height=10).pack(side="left")
mtk.ButtonLight(buttonlist, text="PEinjector "+version,
w=140, func=restart_to_update, color_type="success").pack(side="left")
mtk.ButtonLight(buttonlist, text="Hub "+hubversion,
w=100, color_type="primary", func=open_update).pack(side="left")
buttonlist.pack()
mtk.Frame(first_page, w=10000).pack(fill="both", expand=True)
first_page.pack(fill="both", expand=True)
now_frame = first_page
def home_ui(root: mtk.Frame):
global master
2024-05-04 22:28:55 +08:00
home_root_frame = mtk.Frame(root)
master = home_root_frame
2024-05-04 21:27:20 +08:00
show_home_page()
2024-05-04 22:28:55 +08:00
home_root_frame.pack(fill="both", expand=True)
return home_root_frame