Skip to content

Commit f863db6

Browse files
max-muotoAkuli
andauthored
Update tkinter.PhotoImage (#12342)
Co-authored-by: Akuli <[email protected]>
1 parent 1b9e90b commit f863db6

File tree

2 files changed

+66
-12
lines changed

2 files changed

+66
-12
lines changed

stdlib/@tests/stubtest_allowlists/py313.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,6 @@ tkinter.Misc.tk_busy_current
5959
tkinter.Misc.tk_busy_forget
6060
tkinter.Misc.tk_busy_hold
6161
tkinter.Misc.tk_busy_status
62-
tkinter.PhotoImage.copy
63-
tkinter.PhotoImage.copy_replace
64-
tkinter.PhotoImage.data
65-
tkinter.PhotoImage.read
66-
tkinter.PhotoImage.subsample
67-
tkinter.PhotoImage.write
68-
tkinter.PhotoImage.zoom
6962
tkinter.Text.count
7063
tkinter.Wm.wm_attributes
7164
types.MappingProxyType.get

stdlib/tkinter/__init__.pyi

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import _tkinter
22
import sys
33
from _typeshed import Incomplete, StrEnum, StrOrBytesPath
4-
from collections.abc import Callable, Mapping, Sequence
4+
from collections.abc import Callable, Iterable, Mapping, Sequence
55
from tkinter.constants import *
66
from tkinter.font import _FontDescription
77
from types import TracebackType
@@ -3331,9 +3331,33 @@ class PhotoImage(Image, _PhotoImageLike):
33313331
def blank(self) -> None: ...
33323332
def cget(self, option: str) -> str: ...
33333333
def __getitem__(self, key: str) -> str: ... # always string: image['height'] can be '0'
3334-
def copy(self) -> PhotoImage: ...
3335-
def zoom(self, x: int, y: int | Literal[""] = "") -> PhotoImage: ...
3336-
def subsample(self, x: int, y: int | Literal[""] = "") -> PhotoImage: ...
3334+
if sys.version_info >= (3, 13):
3335+
def copy(
3336+
self,
3337+
*,
3338+
from_coords: Iterable[int] | None = None,
3339+
zoom: int | tuple[int, int] | list[int] | None = None,
3340+
subsample: int | tuple[int, int] | list[int] | None = None,
3341+
) -> PhotoImage: ...
3342+
def subsample(self, x: int, y: Literal[""] = "", *, from_coords: Iterable[int] | None = None) -> PhotoImage: ...
3343+
def zoom(self, x: int, y: Literal[""] = "", *, from_coords: Iterable[int] | None = None) -> PhotoImage: ...
3344+
def copy_replace(
3345+
self,
3346+
sourceImage: PhotoImage | str,
3347+
*,
3348+
from_coords: Iterable[int] | None = None,
3349+
to: Iterable[int] | None = None,
3350+
shrink: bool = False,
3351+
zoom: int | tuple[int, int] | list[int] | None = None,
3352+
subsample: int | tuple[int, int] | list[int] | None = None,
3353+
# `None` defaults to overlay.
3354+
compositingrule: Literal["overlay", "set"] | None = None,
3355+
) -> None: ...
3356+
else:
3357+
def copy(self) -> PhotoImage: ...
3358+
def zoom(self, x: int, y: int | Literal[""] = "") -> PhotoImage: ...
3359+
def subsample(self, x: int, y: int | Literal[""] = "") -> PhotoImage: ...
3360+
33373361
def get(self, x: int, y: int) -> tuple[int, int, int]: ...
33383362
def put(
33393363
self,
@@ -3348,7 +3372,44 @@ class PhotoImage(Image, _PhotoImageLike):
33483372
),
33493373
to: tuple[int, int] | None = None,
33503374
) -> None: ...
3351-
def write(self, filename: StrOrBytesPath, format: str | None = None, from_coords: tuple[int, int] | None = None) -> None: ...
3375+
if sys.version_info >= (3, 13):
3376+
def read(
3377+
self,
3378+
filename: StrOrBytesPath,
3379+
format: str | None = None,
3380+
*,
3381+
from_coords: Iterable[int] | None = None,
3382+
to: Iterable[int] | None = None,
3383+
shrink: bool = False,
3384+
) -> None: ...
3385+
def write(
3386+
self,
3387+
filename: StrOrBytesPath,
3388+
format: str | None = None,
3389+
from_coords: Iterable[int] | None = None,
3390+
*,
3391+
background: str | None = None,
3392+
grayscale: bool = False,
3393+
) -> None: ...
3394+
@overload
3395+
def data(
3396+
self, format: str, *, from_coords: Iterable[int] | None = None, background: str | None = None, grayscale: bool = False
3397+
) -> bytes: ...
3398+
@overload
3399+
def data(
3400+
self,
3401+
format: None = None,
3402+
*,
3403+
from_coords: Iterable[int] | None = None,
3404+
background: str | None = None,
3405+
grayscale: bool = False,
3406+
) -> tuple[str, ...]: ...
3407+
3408+
else:
3409+
def write(
3410+
self, filename: StrOrBytesPath, format: str | None = None, from_coords: tuple[int, int] | None = None
3411+
) -> None: ...
3412+
33523413
def transparency_get(self, x: int, y: int) -> bool: ...
33533414
def transparency_set(self, x: int, y: int, boolean: bool) -> None: ...
33543415

0 commit comments

Comments
 (0)