Try this:
In function encfile
replace the call to fiencdone()
with:
root.event_generate("<<encryption_done>>")
Add the following new function definitions after the definition of function encfile
:
def run_encfile():
from threading import Thread
root.bind('<<encryption_done>>', encryption_done)
Thread(target=encfile).start()
def encryption_done(*args):
fiencdone()
Finally, change line 75 to invoke run_encfile
instead of encfile
:
file_enc_button = tk.Button(fibutton_frame, text='Encrypt',font='Raleway 15 bold', width=15,command=run_encfile, borderwidth=3)
This will run the encryption in a separate thread but have the call to fiencdone
signaling that the encryption is complete done in the main thread, which is required since it updates the GUI.