I am very new to programming and im trying to make a very simple GUI. I have a problem with the button freezing until it completes the command. I know one can solve it with Threads, but im not sure how. Here is my code now:
#GUI
from tkinter import *
import time
import threading
window = Tk()
window.title("GTIM" )
window.geometry('360x200')
def clear():
lbl1.destroy()
lbl2.destroy()
btn.destroy()
def prog_bar():
progress.grid()
for i in range(300):
progress['value'] = i
time.sleep(0.01)
progress = Progressbar(window, orient = HORIZONTAL, length = 300, mode = 'determinate')
progress.grid(column=2, row=7)
progress.grid_remove()
lbl1 = Label(window, text="ГТИМ-2020", font=("Times New Roman", 15))
lbl2 = Label(window, text="Генератор на Теми за Играта Асоциации" , font=("Arial Bold", 10))
btn = Button(window, text="Генерирай!", command = lambda: [clear(), prog_bar()])
lbl1.grid(column = 2, row = 0)
lbl2.grid(column = 2, row = 1)
btn.grid(column=2, row=5)
col_count, row_count = window.grid_size()
for col in xrange(col_count):
window.grid_columnconfigure(col, minsize=20)
for row in xrange(row_count):
window.grid_rowconfigure(row, minsize=20)
window.mainloop()
Thanks for the help! Ignore the bulgarian please :D