Reparatur der venv.
This commit is contained in:
@@ -28,10 +28,10 @@ class HDC:
|
||||
methods.
|
||||
"""
|
||||
|
||||
def __init__(self, dc):
|
||||
def __init__(self, dc: int) -> None:
|
||||
self.dc = dc
|
||||
|
||||
def __int__(self):
|
||||
def __int__(self) -> int:
|
||||
return self.dc
|
||||
|
||||
|
||||
@@ -42,10 +42,10 @@ class HWND:
|
||||
methods, instead of a DC.
|
||||
"""
|
||||
|
||||
def __init__(self, wnd):
|
||||
def __init__(self, wnd: int) -> None:
|
||||
self.wnd = wnd
|
||||
|
||||
def __int__(self):
|
||||
def __int__(self) -> int:
|
||||
return self.wnd
|
||||
|
||||
|
||||
@@ -69,19 +69,22 @@ class Dib:
|
||||
defines the size of the image.
|
||||
"""
|
||||
|
||||
def __init__(self, image, size=None):
|
||||
if hasattr(image, "mode") and hasattr(image, "size"):
|
||||
def __init__(
|
||||
self, image: Image.Image | str, size: tuple[int, int] | list[int] | None = None
|
||||
) -> None:
|
||||
if isinstance(image, str):
|
||||
mode = image
|
||||
image = ""
|
||||
else:
|
||||
mode = image.mode
|
||||
size = image.size
|
||||
else:
|
||||
mode = image
|
||||
image = None
|
||||
if mode not in ["1", "L", "P", "RGB"]:
|
||||
mode = Image.getmodebase(mode)
|
||||
self.image = Image.core.display(mode, size)
|
||||
self.mode = mode
|
||||
self.size = size
|
||||
if image:
|
||||
assert not isinstance(image, str)
|
||||
self.paste(image)
|
||||
|
||||
def expose(self, handle):
|
||||
@@ -149,7 +152,9 @@ class Dib:
|
||||
result = self.image.query_palette(handle)
|
||||
return result
|
||||
|
||||
def paste(self, im, box=None):
|
||||
def paste(
|
||||
self, im: Image.Image, box: tuple[int, int, int, int] | None = None
|
||||
) -> None:
|
||||
"""
|
||||
Paste a PIL image into the bitmap image.
|
||||
|
||||
@@ -169,16 +174,16 @@ class Dib:
|
||||
else:
|
||||
self.image.paste(im.im)
|
||||
|
||||
def frombytes(self, buffer):
|
||||
def frombytes(self, buffer: bytes) -> None:
|
||||
"""
|
||||
Load display memory contents from byte data.
|
||||
|
||||
:param buffer: A buffer containing display data (usually
|
||||
data returned from :py:func:`~PIL.ImageWin.Dib.tobytes`)
|
||||
"""
|
||||
return self.image.frombytes(buffer)
|
||||
self.image.frombytes(buffer)
|
||||
|
||||
def tobytes(self):
|
||||
def tobytes(self) -> bytes:
|
||||
"""
|
||||
Copy display memory contents to bytes object.
|
||||
|
||||
@@ -190,13 +195,15 @@ class Dib:
|
||||
class Window:
|
||||
"""Create a Window with the given title size."""
|
||||
|
||||
def __init__(self, title="PIL", width=None, height=None):
|
||||
def __init__(
|
||||
self, title: str = "PIL", width: int | None = None, height: int | None = None
|
||||
) -> None:
|
||||
self.hwnd = Image.core.createwindow(
|
||||
title, self.__dispatcher, width or 0, height or 0
|
||||
)
|
||||
|
||||
def __dispatcher(self, action, *args):
|
||||
return getattr(self, "ui_handle_" + action)(*args)
|
||||
return getattr(self, f"ui_handle_{action}")(*args)
|
||||
|
||||
def ui_handle_clear(self, dc, x0, y0, x1, y1):
|
||||
pass
|
||||
@@ -204,7 +211,7 @@ class Window:
|
||||
def ui_handle_damage(self, x0, y0, x1, y1):
|
||||
pass
|
||||
|
||||
def ui_handle_destroy(self):
|
||||
def ui_handle_destroy(self) -> None:
|
||||
pass
|
||||
|
||||
def ui_handle_repair(self, dc, x0, y0, x1, y1):
|
||||
@@ -213,7 +220,7 @@ class Window:
|
||||
def ui_handle_resize(self, width, height):
|
||||
pass
|
||||
|
||||
def mainloop(self):
|
||||
def mainloop(self) -> None:
|
||||
Image.core.eventloop()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user