TomSchimansky / CustomTkinter

A modern and customizable python UI-library based on Tkinter
MIT License
10.99k stars 1.04k forks source link

Image is not cleared if set to None in configure method #2494

Open janezgolob opened 1 month ago

janezgolob commented 1 month ago

I am not sure if this is supposed to be supported, but I naively expected that my_label.configure(image=None) would clear the image from the label.

https://github.com/TomSchimansky/CustomTkinter/blob/b9b57d95c7d3bb821a2260527315b6079161f5c9/customtkinter/windows/widgets/ctk_label.py#L143

mate02102003 commented 1 month ago

I just checked what is the behavior if you would have done this with the base tkinter library. It doesn't does anything, it just keeps the image the same.

mate02102003 commented 1 month ago

But if you do this:

my_label.configure(image="")

It should clear the image, although you will get a warning its not a CTkImage.

janezgolob commented 1 month ago

Right. I actually ended up with two labels on top of each other, using one of them for text and another one for icons. Just to avoid those warnings. I am totally fine if you keep the same behavior, though I would argue that what tkinter does is more accidental behavior than intentional. Maybe adding a warning would help already.

mate02102003 commented 1 month ago

Hi, I looked into the underlying frameworks documentation, the empty string so "" is the intended way to disable the currently set image. tk label image image

janezgolob commented 4 weeks ago

OK. Fine. May I suggest removing that warning then? This one: https://github.com/TomSchimansky/CustomTkinter/blob/b9b57d95c7d3bb821a2260527315b6079161f5c9/customtkinter/windows/widgets/core_widget_classes/ctk_base_class.py#L179

Although it seems strange at first glance, I agree it is best that customtkinter keeps compatibility with tkinter in this sense as well. Thanks, everyone, for looking into this.