I have my code set up to print out to console it's progress as it loops through a few thousand items. This works perfectly well until I go to package it up and distribute it to others as there is no longer a console. My current method works, but the GUI consistently hangs after a few iterations while the loop continues to run.
The example code below runs, but my loops are much more complicated and hang up. I'm curious if there is a better way to accomplish this as I love using these GUI's but I have yet been able to find a good way of sending data to the GUI while I'm in a different loop.
from tkinter import *
import time
def do_loop(num_cycles):
for i in range(0, int(num_cycles)):
time.sleep(.25)
# print(i)
GUI_MSG.set(str(i))
Tk.update_idletasks(FORM)
FORM = Tk()
GUI_MSG = StringVar()
FORM.wm_title('Perform Element Analysis')
IO_FRAME = LabelFrame(FORM, text=' Input/Output Directories ')
IO_FRAME.grid(row=0, sticky='W', padx=5, pady=5, ipadx=5, ipady=5)
Label(IO_FRAME, text="Numer of Loops").grid(
row=1, column=1, padx=5, pady=(10, 2), sticky='E')
NUMBER_LOOPS = Entry(IO_FRAME, width=10)
NUMBER_LOOPS.grid(row=1, column=2, columnspan=4)
Button(FORM, text='Generate Tables', command=lambda: do_loop(
NUMBER_LOOPS.get())).grid(row=3, column=0, sticky='WE', padx=5, pady=5)
Label(FORM, textvariable=GUI_MSG).grid(row=2, sticky='WE', padx=5, pady=20)
FORM.mainloop()