Tkinter Toplevel widgets not displaying - python -
i working toplevel window in python tkinter , cannot seem embedded widgets show until other code has completed. frame shows up, loops through other code properly, text/progressbar widget show if somehow interrupt loop. frame destroyed @ end. see below.
here toplevel code:
class progresstrack: def __init__(self, master, variable, steps, application): self.progress_frame = toplevel(master) self.progress_frame.geometry("500x140+30+30") self.progress_frame.wm_title("please wait...") self.progress_frame.wm_iconbitmap(bitmap="r:\\chpcomm\\sls\\pssr\\bin\\installation_files\\icon\\psidiarylite.ico") progress_text = canvas(self.progress_frame) progress_text.place(x=20,y=20,width=480,height=60) progress_text.create_text(10, 30, anchor=w, width=460, font=("arial", 12), text="please not use " + application + " during execution. doing so, interrupt execution.") self.progress_bar = progressbar(self.progress_frame, orient='horizontal', length=440, maximum=steps, variable=variable, mode='determinate') self.progress_bar.place(x=20,y=100,width=450,height=20)
and call instance of following class created when user clicks button on master window:
class checklist: def __init__(self, master, var): self.progress = progresstrack(master, 0, 5, 'microsoft word') while var: #my other code self.progress.progress_bar.step() self.progress.progress_frame.destroy()
you have know tkinter single threaded. window (and see on screen) updates appearance when idle (doing nothing) or when call w.update_idletasks()
w
widget. means when in loop, changing progress bar, nothing happen on screen until loop finished.
so new code be
while var: #my other code self.progress.progress_bar.step() self.progress.progress_frame.update_idletasks() self.progress.progress_frame.destroy()
Comments
Post a Comment