I am making a GUI for a project and my supervisor requested that I include a progress bar as each iteration of the program can take up to 7 minutes.
I want the progress bar to pop up in a separate window, and close after the process is finished but, with my current understanding, either I have to close the popup manually or the whole GUI closes at once.
This is a simplified version of the code I'm using
import Tkinter as tk
from ttk import Progressbar
from os import listdir
import threading
import time
root = tk.Tk()
root.title("TCC Image Processing")
def create_tcc(input_bar, input_progress_dialog):
input_bar['maximum'] = 5
input_bar['value'] = 0
for x in range(5):
time.sleep(1)
input_bar['value'] += 1
# this line is where the touble seems to be
input_progress_dialog.destroy()
def run_tcc():
progress_dialog = tk.Toplevel()
progress_dialog.title("TCC Processing")
bar = Progressbar(progress_dialog, orient="horizontal", length=500, value=0, mode="determinate")
bar.grid(row=4, columnspan=2)
t = threading.Thread(target=create_tcc, args=(bar, progress_dialog))
t.start()
tcc_run_button = tk.Button(root, text="RUN", command=lambda:run_tcc())
tcc_run_button.pack()
root.mainloop()
If possible I would like to avoid downloading extra modules that don't come with straight python.