Cannot See Tkinter Image in Window

While using PhotoImage object in Tkinter, the reference must be held. Tkinter does not handle references to the objects truly. If you do not use your own reference, Tkinter just makes the image transparent, just a blank screen.

As an example;

When we write the code without the reference like;

My “caution.gif” seems like;

But only with a line that keeping a reference to the Tkinter object;

Now I can see my “caution.gif” 😊✌

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s