zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
U
T±d#ã@sxddlZddlmZddlmZddlmZdadd„Zdd    „Z    d
d „Z
Gd d „d ƒZ Gdd„dƒZ dd„Z dd„ZdS)éN)ÚBytesIOé)ÚImage)Ú    deprecatecCsRtdkrNz*t dd¡}tjd|jj›ddaWntjk
rLdaYnXtS)NÚ1)rrúPIL:)Údatarr)Ú _pilbitmap_okrÚnewÚtkinterÚ BitmapImageÚimÚidÚTclError)r ©rúBd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\PIL/ImageTk.pyÚ_pilbitmap_check(s 
rcCs@d}d|kr| d¡}nd|kr.t| d¡ƒ}|r<t |¡SdS)NÚfiler)ÚpoprrÚopen)ÚkwÚsourcerrrÚ_get_image_from_kw4s rcCs\|j}z| |||¡Wn>tjk
rVddlm}| | ¡¡| |||¡YnXdS)Nr)Ú
_imagingtk)ÚtkÚcallr rÚrZtkinitZ
interpaddr)ÚcommandÚphotorrrrrrÚ_pyimagingtkcall>s rc@sDeZdZdZddd„Zdd„Zdd„Zd    d
„Zd d „Zdd d„Z    dS)Ú
PhotoImagea3
    A Tkinter-compatible photo image.  This can be used
    everywhere Tkinter expects an image object.  If the image is an RGBA
    image, pixels having alpha 0 are treated as transparent.
 
    The constructor takes either a PIL image, or a mode and a size.
    Alternatively, you can use the ``file`` or ``data`` options to initialize
    the photo image object.
 
    :param image: Either a PIL image, or a mode string.  If a mode string is
                  used, a size must also be given.
    :param size: If the first argument is a mode string, this defines the size
                 of the image.
    :keyword file: A filename to load the image from (using
                   ``Image.open(file)``).
    :keyword data: An 8-bit string containing image data (as loaded from an
                   image file).
    NcKsÐ|dkrt|ƒ}t|dƒr€t|dƒr€|j}|dkrh| ¡| ¡z |jj}Wntk
rfd}YnX|j}|\|d<|d<n|}d}|dkršt     |¡}||_
||_ t j f|Ž|_|jj|_|rÌ| |¡dS)NÚmodeÚsizeÚPÚRGBÚwidthÚheight)rÚLr$ÚRGBA)rÚhasattrr!Zapply_transparencyÚloadZpaletteÚAttributeErrorr"rZ getmodebaseÚ_PhotoImage__modeÚ_PhotoImage__sizer r Ú_PhotoImage__photorÚpaste)ÚselfÚimager"rr!rrrÚ__init__cs. 
 
 
zPhotoImage.__init__cCs@|jj}d|j_z|jj dd|¡Wntk
r:YnXdS©Nr1Údelete)r.ÚnamerrÚ    Exception©r0r5rrrÚ__del__ƒs zPhotoImage.__del__cCs
t|jƒS)zô
        Get the Tkinter photo image identifier.  This method is automatically
        called by Tkinter whenever a PhotoImage object is passed to a Tkinter
        method.
 
        :return: A Tkinter photo image identifier (a string).
        )Ústrr.©r0rrrÚ__str__‹szPhotoImage.__str__cCs
|jdS©zU
        Get the width of the image.
 
        :return: The width, in pixels.
        r©r-r:rrrr%•szPhotoImage.widthcCs
|jdS©zW
        Get the height of the image.
 
        :return: The height, in pixels.
        rr=r:rrrr&szPhotoImage.heightcCsl|dk    rtdddƒ| ¡|j}| ¡r<|j|jkr<|}n| |j|j¡}| ||¡t    d|j
|j ƒdS)a´
        Paste a PIL image into the photo image.  Note that this can
        be very slow if the photo image is displayed.
 
        :param im: A PIL image. The size must match the target region.  If the
                   mode does not match, the image is converted to the mode of
                   the bitmap image.
        :param box: Deprecated. This parameter will be removed in Pillow 10
                    (2023-07-01).
        NzThe box parameteré
ZPyImagingPhoto) rr*r Zisblockr!r,Z    new_blockr"Zconvert2rr.r)r0r Zboxr1Úblockrrrr/¥s   zPhotoImage.paste)NN)N)
Ú__name__Ú
__module__Ú __qualname__Ú__doc__r2r8r;r%r&r/rrrrr Os
 
r c@s:eZdZdZd dd„Zdd„Zdd„Zd    d
„Zd d „ZdS)r aä
    A Tkinter-compatible bitmap image.  This can be used everywhere Tkinter
    expects an image object.
 
    The given image must have mode "1".  Pixels having value 0 are treated as
    transparent.  Options, if any, are passed on to Tkinter.  The most commonly
    used option is ``foreground``, which is used to specify the color for the
    non-transparent parts.  See the Tkinter documentation for information on
    how to specify colours.
 
    :param image: A PIL image.
    NcKsf|dkrt|ƒ}|j|_|j|_tƒrH| ¡d|jj›|d<||_    n | 
¡|d<t j f|Ž|_ dS)Nrr)rr!Z_BitmapImage__moder"Ú_BitmapImage__sizerr*r rZ_BitmapImage__imZtobitmapr r Ú_BitmapImage__photo)r0r1rrrrr2Òs zBitmapImage.__init__cCs@|jj}d|j_z|jj dd|¡Wntk
r:YnXdSr3)rFr5rrr6r7rrrr8äs zBitmapImage.__del__cCs
|jdSr<©rEr:rrrr%ìszBitmapImage.widthcCs
|jdSr>rGr:rrrr&ôszBitmapImage.heightcCs
t|jƒS)z÷
        Get the Tkinter bitmap image identifier.  This method is automatically
        called by Tkinter whenever a BitmapImage object is passed to a Tkinter
        method.
 
        :return: A Tkinter bitmap image identifier (a string).
        )r9rFr:rrrr;üszBitmapImage.__str__)N)    rArBrCrDr2r8r%r&r;rrrrr Äs 
r cCs0t d| ¡| ¡f¡}|j}td||jƒ|S)z:Copies the contents of a PhotoImage to a PIL image memory.r(ZPyImagingPhotoGet)rr
r%r&r rr)rr r@rrrÚgetimagesrHcCsLGdd„dtjƒ}tjs$d}t|ƒ‚t ¡}|r:| |¡|||ƒ ¡dS)z!Helper for the Image.show method.cseZdZ‡fdd„Z‡ZS)z_show.<locals>.UIcsD|jdkrt|d|d|_nt||d|_tƒj||jddddS)NrZwhite)Z
foregroundÚmaster)rIZblackr)r1ÚbgZbd)r!r r1r Úsuperr2)r0rIr ©Ú    __class__rrr2s
z_show.<locals>.UI.__init__)rArBrCr2Ú __classcell__rrrLrÚUIsrOztkinter not initializedN)r ZLabelZ _default_rootÚOSErrorZToplevelÚtitleÚpack)r1rQrOÚmsgÚtoprrrÚ_shows
rU)r ÚiorrrZ
_deprecaterr    rrrr r rHrUrrrrÚ<module>s    
uC