I am using Tkinker for creating a progress bar in my Django project. Firstly I try to use Celery but I cannot do it so I looked for other alternatives and I found that. I implement Tkinker to my project and it works but after the window opens and the code is running but the window stops working. say not response. Like that:
How can I work this? And this is my code:
class myFunction():
def __init__(self, user, password, url, port, db_password, username):
self.zaman = datetime.now().strftime("%Y-%m-%d")
...
self.download_all(user, password, url, port, db_password)
...
def download_all(self, user, password, url, port, db_password):
# creating tkinter window
root = Tk()
# Progress bar widget
progress = Progressbar(root, orient=HORIZONTAL,
length=100, mode='determinate')
root.title("Sending")
root.attributes("-topmost", True)
w = root.winfo_reqwidth()
h = root.winfo_reqheight()
ws = root.winfo_screenwidth()
hs = root.winfo_screenheight()
x = (ws / 2) - (w / 2)
y = (hs / 2) - (h / 2)
root.geometry('+%d+%d' % (x, y))
try:
sys.path.append('../')
...
bar = Bar('Processing', max=len(scans))
# try download and save scans into each folder the belong to
pb_length = len(scans)
print("------pb length-----------")
print(pb_length)
pb_value = 100/pb_length
print("------pb val-----------")
print(pb_value)
for s in scans:
progress['value'] = pb_value
root.update_idletasks()
bar.next()
scanner.scan_name = s['name']
scanner.scan_id = s['id']
...
progress.pack(pady=10)
bar.finish()
else:
...
except KeyError and ConnectionError:
pass