Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion stdlib/3/tkinter/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ _Cursor = Union[str, Tuple[str], Tuple[str, str], Tuple[str, str, str], Tuple[st
_EntryValidateCommand = Union[
Callable[[], bool], str, _TkinterSequence[str]
] # example when it's sequence: entry['invalidcommand'] = [entry.register(print), '%P']
_ImageSpec = Union[Image, str] # str can be from e.g. tkinter.image_names()
_ImageSpec = Union[_Image, str] # str can be from e.g. tkinter.image_names()
_Padding = Union[
_ScreenUnits,
Tuple[_ScreenUnits],
Expand Down Expand Up @@ -2831,6 +2831,12 @@ class OptionMenu(Menubutton):
# configure, config, cget are inherited from Menubutton
# destroy and __getitem__ are overrided, signature does not change

class _Image(Protocol):
tk: _tkinter.TkappType
def __del__(self) -> None: ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__del__ being part of a protocol seems odd, does tk really require it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I...don't really know. If there's documentation anywhere on what an image class should define to be tkinter-compatible, I haven't been able to find it. I just included all the methods that are present on both tkinter.Image and PIL.ImageTk.PhotoImage (except __str__).

def height(self) -> int: ...
def width(self) -> int: ...

class Image:
name: Any
tk: _tkinter.TkappType
Expand Down