-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tkinter _Image
hack
#11721
Comments
This seems reasonable. Basically, this type alias would be changed to typeshed/stdlib/tkinter/__init__.pyi Line 181 in 130a049
The most common use cases for tkinter images are setting a window icon with Another option, if it works, is to just import Pillow's type in tkinter stubs with a |
One more option would be to make a protocol that matches the class _PillowPhotoImage:
def width(self) -> int: ...
def height(self) -> int: ...
def paste(self, im: Any, /) -> None: ... It's unlikely that anything matches this accidentally, and autocompletions will show a somewhat useful |
Currently, tkinter uses a hack to mark classes compatible with the
image
parameter:typeshed/stdlib/tkinter/__init__.pyi
Lines 3276 to 3280 in 130a049
Classes implementing this interface are expected to derive from this stub-only class (or one of its sub-classes). Our Pillow stubs did so. Unfortunately, now that Pillow has its own type annotations, I think it's unreasonable for them to do so at runtime. I think our best bet is to change change
_Image
toAny
here, as this interface can't be represented in our type system.Cc @Akuli
The text was updated successfully, but these errors were encountered: