From 956514688ce78a283ae75ebf01b5688d0c8ac330 Mon Sep 17 00:00:00 2001 From: Headshotnoby Date: Tue, 22 Jun 2021 16:36:08 -0400 Subject: [PATCH] add simple tkinter gui to install_update.py --- install_update.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/install_update.py b/install_update.py index c0eb541..509a18f 100644 --- a/install_update.py +++ b/install_update.py @@ -1,4 +1,6 @@ import zipfile, tarfile, platform, os, time, shutil +from tkinter import Tk, HORIZONTAL +from tkinter.ttk import Progressbar, Label ext = { "Windows": "zip", @@ -12,18 +14,32 @@ def extractzip(): # Mac if platform.system() == "Darwin": shutil.rmtree("AO2XP.app", ignore_errors=True) # delete the old app package. archive.extractall() # extract the new version + if os.path.exists("appbase"): # on a mac with the base folder moved out of .app Resources folder + os.system("mv appbase AO2XP.app/Contents/Resources/") # put it back in place + def extractgz(): # Linux archive = tarfile.open("update.tar.gz") archive.extractall() if os.path.exists("update." + ext[platform.system()]): - print "Waiting 3 seconds for AO2XP to close..." + window = Tk() + window.title("AO2XP updater") + window.wm_resizable(0,0) + window.geometry("256x56") + lb = Label(window) + lb.pack() + pb = Progressbar(orient=HORIZONTAL, mode="indeterminate") + pb.pack() + pb.start() + + lb["text"] = "Waiting 3 seconds for AO2XP to close..." time.sleep(3) - print "Extracting update." + ext[platform.system()] + "..." + lb["text"] = "Extracting update." + ext[platform.system()] + "..." globals()["extract" + ext[platform.system()]]() # call the extract function according to OS - print "Done!" + lb["text"] = "Done!\nYou can now start AO2XP." os.remove("update." + ext[platform.system()]) + time.sleep(4) else: print "This program will be automatically run by AO2XP to apply updates.\nYou do not need to run this yourself."