def open_zip(self):
pack = filedialog.askopenfile("r", initialdir=self.resourcepack_location)
found_pack = False
if pack:
amount = functions.zip_files(pack.name)
progress = dialog.ProgressWindow(self.parent, title="Opening Zip", maximum=amount)
count = 0
with zipfile.ZipFile(pack.name, "r") as z:
for file in z.namelist():
if file == "pack.mcmeta":
# messagebox.showinfo("Information", "Found 'pack.mcmeta'.")
found_pack = True
self.destroy()
if found_pack:
self.parent.d = tempfile.TemporaryDirectory()
for file in z.namelist():
z.extract(file, self.parent.d.name)
count += 1
progress.variable_name.set("Current File: " + file)
progress.variable_percent.set("{}% Complete".format(round(100 * float(count) / float(amount))))
progress.variable_progress.set(progress.variable_progress.get() + 1)
self.parent.name = pack.name.split("/")[-1].split(".")[0]
self.parent.directory = self.parent.d.name
self.parent.directory_real = pack.name
self.parent.cmd.tree_refresh()
self.destroy()
elif not found_pack:
messagebox.showerror("Error", "Could not find 'pack.mcmeta'.")
pack.close()
progress.destroy()
评论列表
文章目录