Python, Tkinter: Why Is This Jpeg Not Showing?
Solution 1:
This is a wild guess now, but I just remembered a similar problem. I was able to reproduce your "blue box" this way, so this might be your problem, too. I'll just give it a try.
I assume that the PhotoImage is created in some other scope (maybe a method showImage(self, id)
or something like that) and no reference to it is kept beyond the scope of this method. This has the effect that the PhotoImage
will be garbage-collected at the end of this method, even though it is used in the Label!
Try creating a variable that exists for the whole life time of the frame and bind the PhotoImage to that variable (e.g. self.images[ID]
when using a class for the GUI, or some global variable otherwise). If I am right, and this is indeed the problem, then this should help.
Post a Comment for "Python, Tkinter: Why Is This Jpeg Not Showing?"