Skip to content Skip to sidebar Skip to footer

Tkinter Toplevel Widgets Not Displaying - Python

I am working with a Toplevel window in python Tkinter and I cannot seem to get the embedded widgets to show up until my other code has completed. The frame shows up, it loops throu

Solution 1:

You have to know that tkinter is single threaded. Also the window (and all you see on the screen) updates its appearance only when idle (doing nothing) or when you call w.update_idletasks() where w is any widget. This means when you are in a loop, changing a progress bar, nothing will happen on the screen until the loop is finished.

So your new code could now be

whilevar:
        #MY OTHER CODEself.progress.progress_bar.step()
        self.progress.progress_frame.update_idletasks()
    self.progress.progress_frame.destroy()

Solution 2:

Based upon the @Eric Levieil's link above, it was as simple as adding this to my code:

self.progress.progress_frame.update()

Full change:

classChecklist:def__init__(self, master, var):
        self.progress = ProgressTrack(master, 0, 5, 'Microsoft Word')

        whilevar:#MY OTHER CODEself.progress.progress_bar.step()
            self.progress.progress_frame.update()
        self.progress.progress_frame.destroy()

Thank you Eric!

Post a Comment for "Tkinter Toplevel Widgets Not Displaying - Python"