K iddlmZddlZddlmZddlmZddlmZm Z dZ e rddl m Z dd Z dd ZGd d ZGd dZddZy)) annotationsN)BytesIO)Any)Image ImageFileF) CapsuleTypecd}d|vr|jd}nd|vrt|jd}|sytj|S)Nfiledata)poprropen)kwsources Q/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/PIL/ImageTk.py_get_image_from_kwr+sI F | 2(  ::f c |j} |j||t|y#tj$rDddlm}|j|j|j||t|YywxYw)Nr) _imagingtk) tkcallreprtkinterTclErrorrtkinit interpaddr)commandphotoptrrrs r_pyimagingtkcallr!6sh B+ S *   + !"--/* S * +s+ABBcTeZdZdZ d d dZd dZd dZd dZd dZddZ y) 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). Nc :| t|}| d}t|t|tr|}d}|yd}t||j}|dk(rD|j |j |jr|jjnd}|j}|\|d<|d<|dvrtj|}||_ ||_ tjdi||_|jj |_|r|j#|yy) NImage is requiredz+If first argument is mode, size is requiredPRGBwidthheight)1Lr'RGBA)r ValueError isinstancestrmodeapply_transparencyloadpalettesizer getmodebase_PhotoImage__mode_PhotoImage__sizerr#_PhotoImage__photorpaste)selfimager5rmsgr1s r__init__zPhotoImage.__init__]s =&r*E =%CS/ ! s #DE|C o%::Ds{((* -2]]u}}))::D(, %BwKH 0 0$$T*D  ))/B/ ,,//  JJu  rc |jj}d|j_ |jjj dd|y#t$rYywxYw#t $rYywxYwNr<delete)r9nameAttributeErrorrr Exceptionr;rBs r__del__zPhotoImage.__del__j <<$$D!   LLOO (D 9        "A'A! AA! A-,A-c,t|jS)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). )r0r9r;s r__str__zPhotoImage.__str__4<<  rc |jdSzU Get the width of the image. :return: The width, in pixels. rr8rJs rr(zPhotoImage.width {{1~rc |jdSzW Get the height of the image. :return: The height, in pixels. rrOrJs rr)zPhotoImage.heightrPrc`|j}|j}|jr|j|jk7rRt j j|j|j}|j|||j}td|j|y)aF 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. PyImagingPhotoN) getimimisblockr1r7rcore new_blockr5convert2r r!r9)r;rVr r<blocks rr:zPhotoImage.pastesvhhj}}"''T[["8JJ((bgg>E NN5% ())C)4<<=r)NN)r<zImage.Image | str | Noner5ztuple[int, int] | NonerrreturnNoner\r]r\r0r\int)rV Image.Imager\r]) __name__ __module__ __qualname____doc__r>rFrKr(r)r:r-rrr#r#IsT*+/'+'''%' '  'R !>rr#c:eZdZdZdd dZd dZd dZd dZd dZy) BitmapImagea 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. Nc | t|}| d}t||j|_|j|_t jdd|ji||_ y)Nr%r r-) rr.r1_BitmapImage__moder5_BitmapImage__sizerrhtobitmap_BitmapImage__photo)r;r<rr=s rr>zBitmapImage.__init__s\ =&r*E =%CS/ !jj jj **G0@GBG rc |jj}d|j_ |jjj dd|y#t$rYywxYw#t $rYywxYwr@)rmrBrCrrrDrEs rrFzBitmapImage.__del__rGrHc |jdSrNrkrJs rr(zBitmapImage.widthrPrc |jdSrRrprJs rr)zBitmapImage.heightrPrc,t|jS)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). )r0rmrJs rrKzBitmapImage.__str__rLr)N)r<zImage.Image | Nonerrr\r]r^r`r_) rcrdrerfr>rFr(r)rKr-rrrhrhs!  H !rrhctjd|j|jf}t d||j |S)z:Copies the contents of a PhotoImage to a PIL image memory.r,PyImagingPhotoGet)rnewr(r)r!rU)rrVs rgetimagervs; 6EKKM5<<>: ;B(%< Ir)rzdict[str, Any]r\zImageFile.ImageFile | None)rr0rzPhotoImage | tkinter.PhotoImager r r\r])rr#r\rb) __future__rriortypingrrrr TYPE_CHECKING_typingr rr!r#rhrvr-rrr|sh6# $  +  +8 +?J +  +&s>s>t>!>!Br