CoolFace
Apppublic

Aluode/PerceptionLabPortable

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
ImageTk.cpython-310.pyc92 linesDownload Raw Back to __pycache__
1o

2��Yi� �@s�ddlmZddlZddlmZddlmZddlmZm	Z	dZ3e4r(ddlmZdd
d�Z
d dd�ZGdd�d�ZGdd�d�Zd!dd�ZdS)"�)�annotationsN)�BytesIO)�Any�)�Image�	ImageFileF)�CapsuleType�kw�dict[str, Any]�return�ImageFile.ImageFile | NonecCs@d}d|vr|�d�}nd|vrt|�d��}|sdSt�|�S)N�file�data)�poprr�open)r	�source�r�uE:\DocsHouse\542 percep lab latest\PerceptionLab\PerceptionLab_Portable\python_embed\Lib\site-packages\PIL/ImageTk.py�_get_image_from_kw+s5r�command�str�photo�PhotoImage | tkinter.PhotoImage�ptrr�Nonec	Csb|j}z|�||t|��WdStjy0ddlm}|�|���|�||t|��YdSw)Nr)�6_imagingtk)	�tk�call�repr�tkinterZTclError�rZtkinitZ7interpaddr)rrrrrrrr�_pyimagingtkcall6s�r!c@sReZdZdZ		dddd�Zdd
d�Zddd�Zddd�Zddd�Zd dd�Z	dS)!�8PhotoImagea39    A Tkinter-compatible photo image.  This can be used10    everywhere Tkinter expects an image object.  If the image is an RGBA11    image, pixels having alpha 0 are treated as transparent.12 13    The constructor takes either a PIL image, or a mode and a size.14    Alternatively, you can use the ``file`` or ``data`` options to initialize15    the photo image object.16 17    :param image: Either a PIL image, or a mode string.  If a mode string is18                  used, a size must also be given.19    :param size: If the first argument is a mode string, this defines the size20                 of the image.21    :keyword file: A filename to load the image from (using22                   ``Image.open(file)``).23    :keyword data: An 8-bit string containing image data (as loaded from an24                   image file).25    N�image�Image.Image | str | None�size�tuple[int, int] | Noner	rrrcKs�|durt|�}|durd}t|��t|t�r&|}d}|dur%d}t|��n#|j}|dkr>|��|��|jr<|jjnd}|j}|\|d<|d<|dvrRt	�26|�}||_||_t
jdi|��|_|jj|_|ro|�|�dSdS)	N�Image is requiredz+If first argument is mode, size is required�P�RGB�width�height)�1�Lr)�RGBAr)r�27ValueError�28isinstancer�modeZapply_transparency�load�paletter%rZgetmodebase�_PhotoImage__mode�_PhotoImage__sizerr"�_PhotoImage__photor�paste)�selfr#r%r	�msgr1rrr�__init__]s829�3031�zPhotoImage.__init__cC�Xz|jj}Wn32tyYdSwd|j_z|jj�dd|�WdSty+YdSw�Nr#�delete)r6�name�AttributeErrorrr�	Exception�r8r>rrr�__del__����zPhotoImage.__del__rcC�33t|j�S)z�34        Get the Tkinter photo image identifier.  This method is automatically35        called by Tkinter whenever a PhotoImage object is passed to a Tkinter36        method.37 38        :return: A Tkinter photo image identifier (a string).39        )rr6�r8rrr�__str__��40zPhotoImage.__str__�intcC�41|jdS�zU42        Get the width of the image.43 44        :return: The width, in pixels.45        r�r5rErrrr*��46zPhotoImage.widthcCrI�zW47        Get the height of the image.48 49        :return: The height, in pixels.50        rrKrErrrr+�rLzPhotoImage.height�im�Image.ImagecCsX|��}|j}|��r|j|jkr#tj�|j|j�}|�	||�|j51}td|j|�dS)aF52        Paste a PIL image into the photo image.  Note that this can53        be very slow if the photo image is displayed.54 55        :param im: A PIL image. The size must match the target region.  If the56                   mode does not match, the image is converted to the mode of57                   the bitmap image.58        ZPyImagingPhotoN)
�getimrNZisblockr1r4r�coreZ	new_blockr%Zconvert2rr!r6)r8rNrr#�blockrrrr7�s59zPhotoImage.paste)NN)r#r$r%r&r	rrr�rr�rr�rrH)rNrOrr)60�__name__�61__module__�__qualname__�__doc__r:rBrFr*r+r7rrrrr"Is�62)6364 65 66r"c@sDeZdZdZddd	d67�Zddd�Zddd�Zddd�Zddd�ZdS)�BitmapImagea�68    A Tkinter-compatible bitmap image.  This can be used everywhere Tkinter69    expects an image object.70 71    The given image must have mode "1".  Pixels having value 0 are treated as72    transparent.  Options, if any, are passed on to Tkinter.  The most commonly73    used option is ``foreground``, which is used to specify the color for the74    non-transparent parts.  See the Tkinter documentation for information on75    how to specify colours.76 77    :param image: A PIL image.78    Nr#�Image.Image | Noner	rrrcKsR|durt|�}|durd}t|��|j|_|j|_tjdd|��i|��|_	dS)Nr'rr)79rr/r1Z_BitmapImage__moder%�_BitmapImage__sizerrZZtobitmap�_BitmapImage__photo)r8r#r	r9rrrr:�szBitmapImage.__init__cCr;r<)r]r>r?rrr@rArrrrB�rCzBitmapImage.__del__rHcCrIrJ�r\rErrrr*�rLzBitmapImage.widthcCrIrMr^rErrrr+�rLzBitmapImage.heightrcCrD)z�80        Get the Tkinter bitmap image identifier.  This method is automatically81        called by Tkinter whenever a BitmapImage object is passed to a Tkinter82        method.83 84        :return: A Tkinter bitmap image identifier (a string).85        )rr]rErrrrF�rGzBitmapImage.__str__)N)r#r[r	rrrrSrUrT)	rVrWrXrYr:rBr*r+rFrrrrrZ�s
86
8788rZrOcCs,t�d|��|��f�}td||���|S)z:Copies the contents of a PhotoImage to a PIL image memory.r.ZPyImagingPhotoGet)r�newr*r+r!rP)rrNrrr�getimagesr`)r	r89rr)rrrrrrrr)rr"rrO)�90__future__rr�ior�typingrr rr�
TYPE_CHECKINGZ_typingrrr!r"rZr`rrrr�<module>s9192zA
Aluode/PerceptionLabPortable · CoolFace