-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRePKG-GUIv0.2.2.py
177 lines (135 loc) · 5.19 KB
/
RePKG-GUIv0.2.2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import os.path
import subprocess
import tkinter as tk
import tkinter
from tkinter import filedialog
import json
from PIL import Image, ImageTk
RePKG_path = ''
save_path = ''
wallpaper = []
# RePKG_path
with open('RePKG-path.txt', 'r', encoding='utf-8') as file:
lines = file.readlines()
if len(lines) != 0:
RePKG_path = lines[0].strip()
# save_path
with open('save-path.txt', 'r', encoding='utf-8') as file:
lines = file.readlines()
if len(lines) != 0:
save_path = lines[0].strip()
def choose_RePKG():
# 设置文件对话框将会打开的文件类型
filetypes = (
('Executable files', '*.exe'),
('All files', '*.*')
)
global RePKG_path
# 打开文件选择对话框,并获取选择的文件路径
RePKG_path = filedialog.askopenfilename(
title='打开文件',
initialdir='/',
filetypes=filetypes
)
entry_RePKG.insert(0, RePKG_path)
with open('RePKG-path.txt', 'w', encoding='utf-8') as RePKG:
RePKG.writelines(RePKG_path)
def choose_wallpaper():
# 设置文件对话框将会打开的文件类型
filetypes = (
('Package files', '*.pkg'),
('All files', '*.*')
)
# 打开文件选择对话框,并获取选择的文件路径
path = filedialog.askopenfilename(
title='打开文件',
initialdir='/',
filetypes=filetypes
)
wallpaper.append(path)
a = 0
b = 0
for wallpaper_path in wallpaper:
entry_wallpaper.insert(0, wallpaper_path)
a = a + 75
if a == 75 * 6:
a = 75
b = b + 35
# 打开一个PNG图片文件
image = Image.open("red.png")
# 调整图片大小,这里假设我们将图片调整为宽200像素,高150像素
image = image.resize((50, 35), Image.LANCZOS)
# 将PIL图像转换为Tkinter可以使用的格式
photo = ImageTk.PhotoImage(image)
# 创建一个标签,并将图片放置在标签上
label = tk.Label(root, image=photo)
label.image = photo # 保持对图片的引用
label.place(x=115+a, y=350+b)
def choose_save():
global save_path
# 打开文件选择对话框,并获取选择的文件路径
save_path = filedialog.askdirectory()
entry_save.insert(0, save_path)
with open('save-path.txt', 'w', encoding='utf-8') as save:
save.writelines(save_path)
def extract():
a = 0
b = 0
for wallpaper_path in wallpaper:
extract = RePKG_path + ' extract ' + wallpaper_path + ' -o ' + save_path
subprocess.run(extract, capture_output=True, text=True)
a = a + 75
if a == 75 * 6:
a = 75
b = b + 35
# 打开一个PNG图片文件
image = Image.open("green.png")
# 调整图片大小,这里假设我们将图片调整为宽200像素,高150像素
image = image.resize((50, 35), Image.LANCZOS)
# 将PIL图像转换为Tkinter可以使用的格式
photo = ImageTk.PhotoImage(image)
# 创建一个标签,并将图片放置在标签上
label = tk.Label(root, image=photo)
label.image = photo # 保持对图片的引用
label.place(x=115 + a, y=350 + b)
label_OK = tk.Label(root, text='提取完成')
label_OK.place(x=343, y=440)
# 创建主窗口
root = tk.Tk()
root.title('RePKG')
root.geometry('720x490')
# RePKG
button_RePKG = tk.Button(root, text='选择文件', command=choose_RePKG) # 按钮
button_RePKG.place(x=600, y=50)
label_RePKG = tk.Label(root, text='RePKG程序位置') # 字
label_RePKG.place(x=320, y=20)
entry_RePKG = tkinter.StringVar() # 文本框
entry_RePKG = tkinter.Entry(root, textvariable=entry_RePKG, font=('FangSong', 15), width=40, state='normal')
entry_RePKG.place(x=150, y=55)
entry_RePKG.insert(0, RePKG_path)
# wallpaper
button_wallpaper = tk.Button(root, text="选择文件", command=choose_wallpaper) # 按钮
button_wallpaper.place(x=600, y=310)
label_wallpaper = tk.Label(root, text='wallpaper壁纸pkg文件位置') # 字
label_wallpaper.place(x=285, y=260)
entry_wallpaper = tkinter.StringVar() # 文本框
entry_wallpaper = tkinter.Entry(root, textvariable=entry_wallpaper, font=('FangSong', 15), width=40, state='normal')
entry_wallpaper.place(x=150, y=315)
# 保存
button_save = tk.Button(root, text="选择文件", command=choose_save) # 按钮
button_save.place(x=600, y=180)
label_save = tk.Label(root, text='保存位置') # 字
label_save.place(x=340, y=140)
entry_save = tkinter.StringVar() # 文本框
entry_save = tkinter.Entry(root, textvariable=entry_save, font=('FangSong', 15), width=40, state='normal')
entry_save.place(x=150, y=185)
entry_save.insert(0, save_path)
# 提取
button_extract = tk.Button(root, text='提取', command=extract) # 字
button_extract.place(x=315, y=400)
button_extract.config(width=14, height=1)
# 完成提取
label = tk.Label(root, text='提取完成后打开 -> 保存的位置 -> materials') # 字
label.place(x=450, y=470)
# 运行主循环
root.mainloop()