
    ]HjM(              	      z   % S SK Jr  S SKrS SKrS SKrS SKrS SKrS SKJr  S SK	J
r
  SSKJr  / rS\S'   S+S,S	 jjrS-S.S
 jjr " S S5      r " S S\5      r\R&                  S:X  a  \" \5         " S S\5      r\R&                  S:X  a  \" \5         " S S\R*                  \5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r\R&                  S;  a  \R8                  " S 5      (       a  \" \5        \R8                  " S!5      (       a  \" \5        \R8                  " S"5      (       a  \" \5        \R8                  " S#5      (       a  \" \5        \R8                  " S$5      (       a  \" \5         " S% S&\5      r S S'KJr   \" \5        \"S(:X  at  \#" \RH                  5      S):  a  \%" S*5        \RL                  " 5         \RN                  " \RH                  S   5       r(\%" \" \(/\RH                  S)S Q76 5        SSS5        gg! \! a     Nf = f! , (       d  f       g= f)/    )annotationsNquote)Any   )Imagezlist[Viewer]_viewersc                    [        U [        5      (       a  [        U [        5      (       a  U " 5       n US:  a  [        R                  U 5        g[        R                  SU 5        g)a  
The :py:func:`register` function is used to register additional viewers::

    from PIL import ImageShow
    ImageShow.register(MyViewer())  # MyViewer will be used as a last resort
    ImageShow.register(MySecondViewer(), 0)  # MySecondViewer will be prioritised
    ImageShow.register(ImageShow.XVViewer(), 0)  # XVViewer will be prioritised

:param viewer: The viewer to be registered.
:param order:
    Zero or a negative integer to prepend this viewer to the list,
    a positive integer to append it.
r   N)
isinstancetype
issubclassViewerr	   appendinsert)viewerorders     O/Users/admin/workspace/tools/venv/lib/python3.13/site-packages/PIL/ImageShow.pyregisterr      sE     &$Jvv$>$>qy6"    c                V    [          H  nUR                  " U 4SU0UD6(       d  M    g   g)z
Display a given image.

:param image: An image object.
:param title: Optional title. Not all viewers can display the title.
:param \**options: Additional viewer options.
:returns: ``True`` if a suitable viewer was found, ``False`` otherwise.
titleTF)r	   show)imager   optionsr   s       r   r   r   3   s/     ;;u5E5W55  r   c                      \ rS rSr% SrSS jrSrS\S'    0 rS\S'    SS	 jr	SS
 jr
SS jrSS jrSS jrSS jrSrg)r   B   zBase class for viewers.r   c                
   UR                   S;   da  U R                  S:X  a  UR                   S;   dA  [        R                  " UR                   5      nUR                   U:w  a  UR	                  U5      nU R
                  " U40 UD6$ )zk
The main function for displaying an image.
Converts the given image to the target format and displays it.
)1RGBAPNG)zI;16LA)modeformatr   getmodebaseconvert
show_image)selfr   r   bases       r   r   Viewer.showG   si     JJ-'u$~)E$$UZZ0DzzT!d+u000r   N
str | Noner#   zdict[str, Any]c                    U R                   $ )z3Return format name, or ``None`` to save as PGM/PPM.)r#   r'   r   s     r   
get_formatViewer.get_format^   s    {{r   c                    Sn[        U5      e)zR
Returns the command used to display the file.
Not implemented in the base class.
zunavailable in base viewer)NotImplementedErrorr'   filer   msgs       r   get_commandViewer.get_commandb   s    
 +!#&&r   c                \    UR                   " SSU R                  U5      0U R                  D6$ )z+Save to temporary file and return filename.r#    )_dumpr-   r   r,   s     r   
save_imageViewer.save_imagej   s&    {{I$//%"8IDLLIIr   c                F    U R                   " U R                  U5      40 UD6$ )zDisplay the given image.)	show_filer9   r'   r   r   s      r   r&   Viewer.show_imagen   s    ~~dooe4@@@r   c                    [         R                  R                  U5      (       d  [        e[         R                  " U R
                  " U40 UD65        g)
Display given file.
r   )ospathexistsFileNotFoundErrorsystemr4   r'   rB   r   s      r   r<   Viewer.show_filer   s<     ww~~d####
		$""43734r   c                   [        [        SS5      =(       a    [        [        S5      nU(       + =(       a    [        R                  =(       d    [        R
                  " S5      nU(       a  [        R                  " USSU/5        g g )NfrozenF_MEIPASSpython3z-cz<import os, sys, time; time.sleep(20); os.remove(sys.argv[1]))getattrsyshasattr
executableshutilwhich
subprocessPopen)r'   rB   pyinstallerrO   s       r   _remove_path_after_delayViewer._remove_path_after_delay{   sa    c8U3PZ8P%o8#..TV\\)=T
R	 r   r7   r   Image.Imager   r   returnint)r   rX   rY   r*   r2   strr   r   rY   r\   )r   rX   rY   r\   rB   r\   r   r   rY   rZ   )rB   r\   rY   None)__name__
__module____qualname____firstlineno____doc__r   r#   __annotations__r   r-   r4   r9   r&   r<   rU   __static_attributes__r7   r   r   r   r   B   sF    !1$ FJ/ G^ 7'JAr   r   c                  :    \ rS rSrSrSrSSS.rSS jrSS jrS	r	g
)WindowsViewer   zNThe default viewer on Windows is the default system application for PNG files.r    r   Tcompress_levelsave_allc                ^    SU;   a  Sn[        U5      eUR                  SS5      nSU SU S3$ )N"z.Windows filenames cannot contain double quotes%z"%"zstart "Pillow" /WAIT "z)" && ping -n 4 127.0.0.1 >NUL && del /f ")
ValueErrorreplacer1   s       r   r4   WindowsViewer.get_command   sE    $;BCS/!||C'$TF +q"	
r   c                    [         R                  R                  U5      (       d  [        e[        R
                  S:X  a  [         R                  " U5        U R                  U5        g)r@   win32r   )rA   rB   rC   rD   rM   platform	startfilerU   rF   s      r   r<   WindowsViewer.show_file   sF     ww~~d####<<7"LL%%d+r   r7   Nr[   r]   
r_   r`   ra   rb   rc   r#   r   r4   r<   re   r7   r   r   rg   rg      s    XF!"5G	
	r   rg   rs   c                  :    \ rS rSrSrSrSSS.rSS jrSS jrS	r	g
)	MacViewer   z2The default viewer on macOS using ``Preview.app``.r    r   Tri   c                F    SnSU S[        U5       S[        U5       S3nU$ )Nzopen -a Preview.app( z; sleep 20; rm -f z)&r   r'   r2   r   commands       r   r4   MacViewer.get_command   s1     (gYad},>uT{m2Nr   c                    [         R                  R                  U5      (       d  [        e[        R
                  " SSSU/5        U R                  U5        g)r@   openz-azPreview.appr   )rA   rB   rC   rD   rR   callrU   rF   s      r   r<   MacViewer.show_file   sC     ww~~d####}d;<%%d+r   r7   Nr[   r]   rw   r7   r   r   ry   ry      s    <F!"5Gr   ry   darwinc                  T    \ rS rSrSrSSS.r\R                  S
S j5       rSS jr	Sr
g	)
UnixViewer   r    r   Tri   c                    g Nr7   )r'   r2   r   s      r   get_command_exUnixViewer.get_command_ex   s    r   c                N    U R                   " U40 UD6S   nU S[        U5       3$ )Nr   r}   )r   r   r~   s       r   r4   UnixViewer.get_command   s1    %%d6g6q9!E$K=))r   r7   Nr2   r\   r   r   rY   tuple[str, str]r[   )r_   r`   ra   rb   r#   r   abcabstractmethodr   r4   re   r7   r   r   r   r      s.    F!"5G *r   r   c                  ,    \ rS rSrSrSS jrSS jrSrg)		XDGViewer   z+
The freedesktop.org ``xdg-open`` command.
c                    S=p4X44$ )Nxdg-openr7   )r'   r2   r   r   rO   s        r   r   XDGViewer.get_command_ex   s    ))""r   c                    [         R                  R                  U5      (       d  [        e[        R
                  " SU/5        g)r@   r   r   rA   rB   rC   rD   rR   rS   rF   s      r   r<   XDGViewer.show_file   s3     ww~~d####*d+,r   r7   Nr   r]   r_   r`   ra   rb   rc   r   r<   re   r7   r   r   r   r      s    #r   r   c                  @    \ rS rSrSr S       SS jjrS	S jrSrg)
DisplayViewer   zT
The ImageMagick ``display`` command.
This viewer supports the ``title`` parameter.
Nc                >    S=pEU(       a  US[        U5       3-  nXE4$ )Ndisplayz -title r   r'   r2   r   r   r   rO   s         r   r   DisplayViewer.get_command_ex   s-      )(%,00G""r   c                    [         R                  R                  U5      (       d  [        eS/nUR	                  S5      nU(       a  USU/-  nUR                  U5        [        R                  " U5        g)r@   r   r   z-titler   rA   rB   rC   rD   getr   rR   rS   r'   rB   r   argsr   s        r   r<   DisplayViewer.show_file   sa     ww~~d####{G$Xu%%DDr   r7   r   r2   r\   r   r*   r   r   rY   r   r]   r   r7   r   r   r   r      s6     .2## *#>A#	#r   r   c                  ,    \ rS rSrSrSS jrSS jrSrg)	GmDisplayVieweri  z*The GraphicsMagick ``gm display`` command.c                    SnSnXC4$ )Ngmz
gm displayr7   r'   r2   r   rO   r   s        r   r   GmDisplayViewer.get_command_ex  s    
""r   c                    [         R                  R                  U5      (       d  [        e[        R
                  " SSU/5        g)r@   r   r   r   r   rF   s      r   r<   GmDisplayViewer.show_file  s5     ww~~d####$	401r   r7   Nr   r]   r   r7   r   r   r   r     s    4#
r   r   c                  ,    \ rS rSrSrSS jrSS jrSrg)		EogVieweri  z'The GNOME Image Viewer ``eog`` command.c                    SnSnXC4$ )Neogzeog -nr7   r   s        r   r   EogViewer.get_command_ex  s    
""r   c                    [         R                  R                  U5      (       d  [        e[        R
                  " SSU/5        g)r@   r   z-nr   r   rF   s      r   r<   EogViewer.show_file"  s5     ww~~d####%t,-r   r7   Nr   r]   r   r7   r   r   r   r     s    1#
r   r   c                  @    \ rS rSrSr S       SS jjrS	S jrSrg)
XVVieweri,  zL
The X Viewer ``xv`` command.
This viewer supports the ``title`` parameter.
Nc                >    S=pEU(       a  US[        U5       3-  nXE4$ )Nxvz -name r   r   s         r   r   XVViewer.get_command_ex2  s-    
  $#u//G""r   c                    [         R                  R                  U5      (       d  [        eS/nUR	                  S5      nU(       a  USU/-  nUR                  U5        [        R                  " U5        g)r@   r   r   z-namer   r   r   s        r   r<   XVViewer.show_file<  sa     ww~~d####vG$We$$DDr   r7   r   r   r]   r   r7   r   r   r   r   ,  s6     .2## *#>A#	#r   r   )rs   r   r   r   r   r   r   c                  "    \ rS rSrSrSS jrSrg)IPythonVieweriY  z!The viewer for IPython frontends.c                    [        U5        g)Nr   )ipython_displayr=   s      r   r&   IPythonViewer.show_image\  s    r   r7   NrW   )r_   r`   ra   rb   rc   r&   re   r7   r   r   r   r   Y  s
    +r   r   )r   __main__   z.Syntax: python3 ImageShow.py imagefile [title])r   )r   ztype[Viewer] | Viewerr   rZ   rY   r^   r   )r   rX   r   r*   r   r   rY   bool))
__future__r   r   rA   rP   rR   rM   shlexr   typingr    r   r	   rd   r   r   r   rg   rt   ry   ABCr   r   r   r   r   r   rQ   r   IPython.displayr   r   ImportErrorr_   lenargvprintexitr   imr7   r   r   <module>r      s   # 
 	   
   , #,E EVF : <<7] 0 <<8Y
*& 
*
 &J <j $
 $z @ <<**||J||I||D!||E||DF : ] z
388}q>?
	CHHQK	 Bd2%%& 
!	    		 
!	 s   H  9H, H)(H),
H: