Catch AttributeError for BitmapImage.__photo

Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
This commit is contained in:
Alexander Karpinsky 2024-09-26 16:27:55 +04:00 committed by GitHub
parent 11bcd5aaa9
commit b9d1768561
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -219,9 +219,10 @@ class BitmapImage:
self.__photo = tkinter.BitmapImage(data=image.tobitmap(), **kw)
def __del__(self) -> None:
if not hasattr(self, "__photo"):
try:
name = self.__photo.name
except AttributeError:
return
name = self.__photo.name
self.__photo.name = None
try:
self.__photo.tk.call("image", "delete", name)