TKinter shows nothing

As shown in the screenshot below I’d assume there would be something in the little tk widget there.

I still haven’t used tkinter and was just about to start out btw, so this might just be my mistake, but I just can’t find a resolution for this problem

Could you try moving the mainloop function after the rest of your code?

1 Like

That’s the correct answer, I’m just going to elaborate a little bit.

The mainloop() function is basically what runs your tkinter app. It initiates all events, triggers, and simply brings it all to work. However, it blocks anything that goes after it, means that any code written after a mainloop will not be run until you exit it.

In your exact case, nothing is shown because Tkinter enters the mainloop before reading your code that sets the window up, can be described as this for your code:

1. Launch script
2. Launch app (forever)
3. Read code

But if you put janela.mainloop() at the end, it’ll become:

1. Launch script
2. Read code
3. Launch app (forever)

(Well, that was a lot of writing)

1 Like

Very late answer, but thanks. Apparently there was a problem with the output tab for everyone, despite my code being sloppy there, it wasn’t working for anyone. Thanks again

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.