Wednesday, April 29, 2020

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" 😊✌


 

No comments:

Post a Comment

A Sad Story: Don't Invest, Just Prodigalize

Last week, a friend called me, gave some bad news about a company. The company was looking for help since they became a victim of Egregor ra...