mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-03-01 04:52:21 +08:00
Add types for PIL.ImageTk (#9733)
This commit is contained in:
15
stubs/Pillow/@tests/test_cases/check_tk_compat.py
Normal file
15
stubs/Pillow/@tests/test_cases/check_tk_compat.py
Normal file
@@ -0,0 +1,15 @@
|
||||
# Verify that ImageTK images are valid to pass to TK code.
|
||||
from __future__ import annotations
|
||||
|
||||
import tkinter
|
||||
|
||||
from PIL import ImageTk
|
||||
|
||||
photo = ImageTk.PhotoImage()
|
||||
bitmap = ImageTk.BitmapImage()
|
||||
|
||||
tkinter.Label(image=photo)
|
||||
tkinter.Label(image=bitmap)
|
||||
|
||||
tkinter.Label().configure(image=photo)
|
||||
tkinter.Label().configure(image=bitmap)
|
||||
@@ -1,18 +1,52 @@
|
||||
from _typeshed import Incomplete
|
||||
import _tkinter
|
||||
import tkinter
|
||||
from _typeshed import ReadableBuffer, StrOrBytesPath, SupportsRead
|
||||
from typing import Any
|
||||
|
||||
class PhotoImage:
|
||||
tk: Any
|
||||
def __init__(self, image: Incomplete | None = ..., size: Incomplete | None = ..., **kw) -> None: ...
|
||||
def __del__(self) -> None: ...
|
||||
def width(self): ...
|
||||
def height(self): ...
|
||||
def paste(self, im, box: Incomplete | None = ...) -> None: ...
|
||||
from PIL.Image import Image, _Box, _Mode, _Size
|
||||
|
||||
class BitmapImage:
|
||||
def __init__(self, image: Incomplete | None = ..., **kw) -> None: ...
|
||||
class PhotoImage(tkinter._PhotoImageLike):
|
||||
tk: _tkinter.TkappType
|
||||
def __init__(
|
||||
self,
|
||||
image: Image | _Mode | None = None,
|
||||
size: _Size | None = None,
|
||||
*,
|
||||
file: StrOrBytesPath | SupportsRead[bytes] = ...,
|
||||
data: ReadableBuffer = ...,
|
||||
# These are forwarded to tkinter.PhotoImage.__init__():
|
||||
name: str | None = None,
|
||||
cnf: dict[str, Any] = ...,
|
||||
format: str = ...,
|
||||
gamma: float = ...,
|
||||
height: int = ...,
|
||||
palette: int | str = ...,
|
||||
width: int = ...,
|
||||
) -> None: ...
|
||||
def __del__(self) -> None: ...
|
||||
def width(self): ...
|
||||
def height(self): ...
|
||||
def width(self) -> int: ...
|
||||
def height(self) -> int: ...
|
||||
# box is deprecated and unused
|
||||
def paste(self, im: Image, box: _Box | None = ...) -> None: ...
|
||||
|
||||
def getimage(photo): ...
|
||||
class BitmapImage(tkinter._BitmapImageLike):
|
||||
def __init__(
|
||||
self,
|
||||
image: Image | None = None,
|
||||
*,
|
||||
file: StrOrBytesPath | SupportsRead[bytes] = ...,
|
||||
data: ReadableBuffer = ...,
|
||||
# These are forwarded to tkinter.Bitmap.__init__():
|
||||
name: str | None = None,
|
||||
cnf: dict[str, Any] = ...,
|
||||
master: tkinter.Misc | _tkinter.TkappType | None = None,
|
||||
background: tkinter._Color = ...,
|
||||
foreground: tkinter._Color = ...,
|
||||
maskdata: str = ...,
|
||||
maskfile: StrOrBytesPath = ...,
|
||||
) -> None: ...
|
||||
def __del__(self) -> None: ...
|
||||
def width(self) -> int: ...
|
||||
def height(self) -> int: ...
|
||||
|
||||
def getimage(photo: tkinter.PhotoImage) -> Image: ...
|
||||
|
||||
Reference in New Issue
Block a user