Update Picocrypt.py

This commit is contained in:
Evan Su 2021-03-25 15:02:30 -04:00 committed by GitHub
parent 9e32b546df
commit dfb35353e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 4 deletions

View File

@ -65,6 +65,7 @@ headerRsc = False
allFiles = False allFiles = False
draggedFolderPaths = False draggedFolderPaths = False
files = False files = False
filesLoaded = False
adString = "File metadata (used to store some text along with the file):" adString = "File metadata (used to store some text along with the file):"
compressingNotice = "Compressing files together..." compressingNotice = "Compressing files together..."
passwordNotice = "Error. The provided password is incorrect." passwordNotice = "Error. The provided password is incorrect."
@ -1241,6 +1242,8 @@ def prepare():
bindContextMenu() bindContextMenu()
def awaitFiles(): def awaitFiles():
global filesLoaded
selectedInput.set("Loading the file(s) and folder(s) you selected...")
a = open(files,"rb") a = open(files,"rb")
b = a.read().decode("utf-8") b = a.read().decode("utf-8")
a.close() a.close()
@ -1257,13 +1260,17 @@ def awaitFiles():
b = b.replace("\r\n"," ").replace('"',"") b = b.replace("\r\n"," ").replace('"',"")
remove(files) remove(files)
remove(files.replace("files.txt","tmp.txt")) remove(files.replace("files.txt","tmp.txt"))
try:
inputSelected(b) inputSelected(b)
except:
pass
filesLoaded = True
sys.exit(0) sys.exit(0)
# Close window only if not encrypting or decrypting # Close window only if not encrypting or decrypting
def onClose(): def onClose():
global outputFile global outputFile,filesLoaded
if not working: if not working and filesLoaded:
tk.destroy() tk.destroy()
else: else:
force = messagebox.askyesno("Confirmation",cancelNotice) force = messagebox.askyesno("Confirmation",cancelNotice)
@ -1288,7 +1295,7 @@ if __name__=="__main__":
tmp = Thread(target=awaitFiles,daemon=True) tmp = Thread(target=awaitFiles,daemon=True)
tmp.start() tmp.start()
except: except:
pass filesLoaded = True
# Start tkinter # Start tkinter
tk.protocol("WM_DELETE_WINDOW",onClose) tk.protocol("WM_DELETE_WINDOW",onClose)