
    iZ                        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  S SKJr  S SKJrJrJr  S SKJrJr  S SKJr  S S	KJr   S S
KJr  \R:                  " \5      r\R@                  RC                  \RD                  S5      \R@                  RC                  \RD                  S5      \R@                  RC                  \RD                  S5      \R@                  RC                  \RD                  SS5      \R@                  RC                  \RD                  SS5      \R@                  RC                  \RD                  SS5      \R@                  RC                  \RD                  SS5      /r# " S S\5      r$g! \ a    Sr GN2f = f)    N)log)SplashWriter)splash_templates)Target)_check_guts_eq_check_guts_tocmisc)is_aix	is_darwin)	bindepend)
tcltk_info)Imagelicense.termsztext.tclztk.tclttkzttk.tclz	fonts.tclzcursors.tclz	utils.tclc                       \ rS rSrSrS rS\4S\4S\4S\4S\4S	\4S
\4S\4S\4S\4S\4S\4S\4S\4S\4S\4S\4S\4S\44rS r	S r
\S 5       rS r\S 5       rSrg)Splash3   a  
Bundles the required resources for the splash screen into a file, which will be included in the CArchive.

A Splash has two outputs, one is itself and one is stored in splash.binaries. Both need to be passed to other
build targets in order to enable the splash screen.
c                 b  ^ ^ SSK Jn  [        R                  " T 5        [        (       a  [        S5      e[        R                  (       d  [        S5      e[        R                  S5        T R                  5         [        R                  R                  U5      (       d#  [        R                  R                  US   U5      n[        R                  R                  U5      n[        R                  R!                  U5      (       d  [#        SU-  5      eUT l        UR'                  SS	5      T l        UR'                  S
S5      T l        UR'                  SS5      T l        UR'                  SS5      T l        UR'                  SS5      T l        UR'                  SS5      T l        UR'                  SS5      T l        UR'                  SS5      T l        UR'                  SS5      T l        UR'                  SS5      T l        UR'                  SS5      T l        [        R                  R?                  T R@                  5      S   nT R*                  c
  US-   T l        T R,                  c
  US-   T l        [        RB                  T l"        T RG                  T RD                  U5      T l$        [        RK                  ST RH                  5        T RM                  5       T l'        [        RP                  T l)        [        RT                  T l+        T RR                  c   eT RV                  c   e[        RK                  ST RR                  5        [        RK                  S T RV                  5        [Y        [        R                  R[                  T RR                  5      [        R                  R[                  T RV                  5      /[\        Q5      T l.        [        R                  S!5        [        R^                  nT R(                  (       a"  T R\                  Ra                  S" U 5       5        T RR                  T RV                  4 Vs/ s H%  n[        R                  R[                  U5      US#4PM'     n	n[b        Rd                  " U	5      T l3        T R\                  Ra                  S$ T Rf                   5       5        T RH                  (       d%  T Rf                  Ri                  U 4S% jU 5       5        [Y        S& X#-   T Rf                  -    5       5      mU4S' jn
[Y        [k        U
T R\                  5      5      T l.        [        RK                  S(T R\                  5        [l        (       a  [        R                  R?                  T RR                  5      u  pUS):X  a.  [        Rn                  u  pT =RR                  S*U S+U S,3-  sl)        [        R                  R?                  T RV                  5      u  pUS):X  a/  [        Rp                  u  nnT =RV                  S-U S+U S,3-  sl+        T Rs                  5         gs  snf ).a  
:param str image_file:
    A path-like object to the image to be used. Only the PNG file format is supported.

    .. note:: If a different file format is supplied and PIL (Pillow) is installed, the file will be converted
        automatically.

    .. note:: *Windows*: The color ``'magenta'`` / ``'#ff00ff'`` must not be used in the image or text, as it is
        used by splash screen to indicate transparent areas. Use a similar color (e.g., ``'#ff00fe'``) instead.

    .. note:: If PIL (Pillow) is installed and the image is bigger than max_img_size, the image will be resized
        to fit into the specified area.
:param list binaries:
    The TOC list of binaries the Analysis build target found. This TOC includes all extension modules and their
    binary dependencies. This is required to determine whether the user's program uses `tkinter`.
:param list datas:
    The TOC list of data the Analysis build target found. This TOC includes all data-file dependencies of the
    modules. This is required to check if all splash screen requirements can be bundled.

:keyword text_pos:
    An optional two-integer tuple that represents the origin of the text on the splash screen image. The
    origin of the text is its lower left corner. A unit in the respective coordinate system is a pixel of the
    image, its origin lies in the top left corner of the image. This parameter also acts like a switch for
    the text feature. If omitted, no text will be displayed on the splash screen. This text will be used to
    show textual progress in onefile mode.
:type text_pos: Tuple[int, int]
:keyword text_size:
    The desired size of the font. If the size argument is a positive number, it is interpreted as a size in
    points. If size is a negative number, its absolute value is interpreted as a size in pixels. Default: ``12``
:type text_size: int
:keyword text_font:
    An optional name of a font for the text. This font must be installed on the user system, otherwise the
    system default font is used. If this parameter is omitted, the default font is also used.
:keyword text_color:
    An optional color for the text. HTML color codes (``'#40e0d0'``) and color names (``'turquoise'``) are
    supported. Default: ``'black'``
    (Windows: the color ``'magenta'`` / ``'#ff00ff'`` is used to indicate transparency, and should not be used)
:type text_color: str
:keyword text_default:
    The default text which will be displayed before the extraction starts. Default: ``"Initializing"``
:type text_default: str
:keyword full_tk:
    By default Splash bundles only the necessary files for the splash screen (some tk components). This
    options enables adding full tk and making it a requirement, meaning all tk files will be unpacked before
    the splash screen can be started. This is useful during development of the splash screen script.
    Default: ``False``
:type full_tk: bool
:keyword minify_script:
    The splash screen is created by executing an Tcl/Tk script. This option enables minimizing the script,
    meaning removing all non essential parts from the script. Default: ``True``
:keyword name:
    An optional alternative filename for the .res file. If not specified, a name is generated.
:type name: str
:keyword script_name:
    An optional alternative filename for the Tcl script, that will be generated. If not specified, a name is
    generated.
:type script_name: str
:keyword max_img_size:
    Maximum size of the splash screen image as a tuple. If the supplied image exceeds this limit, it will be
    resized to fit the maximum width (to keep the original aspect ratio). This option can be disabled by
    setting it to None. Default: ``(760, 480)``
:type max_img_size: Tuple[int, int]
:keyword always_on_top:
    Force the splashscreen to be always on top of other windows. If disabled, other windows (e.g., from other
    applications) can cover the splash screen by user bringing them to front. This might be useful for
    frozen applications with long startup times. Default: ``True``
:type always_on_top: bool
   )CONFz/ERROR: Splash screen is not supported on macOS.zERROR: Your platform does not support the splash screen feature, since tkinter is not installed. Please install tkinter and try again.z>Verifying Tcl/Tk compatibility with splash screen requirementsspecpathzImage file '%s' not foundfull_tkFnameNscript_nameminify_scriptTmax_img_size)i  i  text_pos	text_size   	text_fontTkDefaultFont
text_colorblacktext_defaultInitializingalways_on_topr   z.resz_script.tclzProgram uses tkinter: %rzUsing Tcl shared library: %rzUsing Tk shared library: %rz/Collect Tcl/Tk data files for the splash screenc              3   *   #    U  H	  oS    v   M     g7fr   N .0entrys     HC:\des-py\RoboSAPF\venv\Lib\site-packages\PyInstaller\building\splash.py	<genexpr>"Splash.__init__.<locals>.<genexpr>   s     +M*!H*   BINARYc              3   *   #    U  H	  oS    v   M     g7fr(   r)   r*   s     r-   r.   r/      s     'LmUamr0   c              3   P   >#    U  H  oS    TR                   ;   d  M  Uv   M     g7fr(   )splash_requirements)r+   r,   selfs     r-   r.   r/      s"      gJ5(dNfNfBfJs   &	&c              3   *   #    U  H	  oS    v   M     g7fr(   r)   r*   s     r-   r.   r/      s     W5U5Ah5Ur0   c                    > U T;  a;  [         R                  R                  U 5      S:X  a  g[        R	                  SU 5        gg)Nr   FzThe local Tcl/Tk installation is missing the file %s. The behavior of the splash screen is therefore undefined and may be unsupported.T)ospathbasenameloggerwarning)filenamecollected_filess    r-   _filter_requirement,Splash.__init__.<locals>._filter_requirement   sD    . 77##H-@ BCK     zSplash Requirements: %sz.az(libtcl.so..)z
(libtk.so.):configr   r   __init__r   
SystemExitr   	availabler;   info_check_tcl_tk_compatibilityr8   r9   isabsjoinnormpathexists
ValueError
image_filegetr   r   r   r   r   r   r   r    r"   r$   r&   splitexttocfilenametkinter_extension_file_tkinter_file_uses_tkinteruses_tkinterdebuggenerate_scriptscripttcl_shared_librarytcl_libtk_shared_librarytk_libsetr:   r4   
data_filesupdater   binary_dependency_analysisbinariesextendfilterr
   tcl_version
tk_version__postinit__)r5   rO   rb   dataskwargsr   root
tcltk_treesrc_name
tcltk_libsr?   _ext	tcl_major	tcl_minortk_majortk_minorr>   s   `                @r-   rE   Splash.__init__:   s   J 	" 9NOO ##8  	TU((* ww}}Z((d:&6
CJWW%%j1
ww~~j))8:EFF %zz)U3JJvt,	!::mT:#ZZ>"JJ~zB 

:t4K4KA **\7;"JJ~~F $ZZ> ww 0 01!499vDI##m3D (>> !..t/A/A8L/1B1BC**,!44 22||'''{{&&&3T\\B2DKK@#& GGT\\*GGT[[)	(

 !(
 $  	EF**
<<$$+++M*+MM Y]XdXdfjfqfqWrsWr8rww''18XFWr
s!<<ZH 	  '''Ldmm'LL   MM   gJ gg WX5E5UWW	  $'v.A4C[C['\#] .0H0HI 6WW%%dll3FAd{'1'='=$	+i[)A FFWW%%dkk2FAd{%/%:%:"(H:QxjBBc ts   ;,X,rO   r   r   r   r   r    r"   r$   r&   r   r   r   rV   rY   r[   r]   r4   rb   rT   c                     [         R                  " XU5      (       a  g[        R                  " U R                  5      U:  a,  [
        R                  SU R                  U R                  5        gg)NTz#Building %s because file %s changedF)r   _check_gutsr	   mtimerO   r;   rH   tocbasename)r5   data
last_builds      r-   rv   Splash._check_guts$  sS    d*55 ::doo&3KK=t?O?OQUQ`Q`arA   c           	        ^  [         R                  ST R                  5        U 4S jn[        T R                  S5      nUR                  S5      S:X  a  UR                  S5        [        R                  " SUR                  S5      5      S	   [        R                  " SUR                  S5      5      S	   4nUT R                  :  a  U" T R                  U5      nGO[        R                  R                  T R                  5      nO[        (       a  [        R                  " T R                  S
S9nUR                  T R                  :  a  U" XUR                  5      nOE[        R                   " 5       nUR#                  USS9  UR%                  5         UR'                  5       n[         R                  ST R                  5        O[)        ST R                  < S35      eUR%                  5         [+        T R                  T R,                  [        R                  R/                  T R0                  5      [        R                  R/                  T R2                  5      [4        R6                  UT R8                  5        g )NzBuilding Splash %sc                   > [         (       Ga/  Uu  p#T
R                  S   U-  nUS:  a  [        X4-  5      nT
R                  S   nT
R                  S   U-  nUS:  a  [        X%-  5      nT
R                  S   n[        U [         R                  5      (       a  U nO[         R
                  " U 5      nUR                  X#45      n[        R                  " 5       nUR                  USS9  UR                  5         UR                  5         UR                  5       n	[        R                  ST
R                  XU5        U	$ [        SUS   US   T
R                  S   T
R                  S   4-  5      e)Nr      PNGformatz/Resized image %s from dimensions %r to (%d, %d)zThe splash image dimensions (w: %d, h: %d) exceed max_img_size (w: %d, h:%d), but the image cannot be resized due to missing PIL.Image! Either install the Pillow package, adjust the max_img_size, or use an image of compatible dimensions.)PILImager   int
isinstancer   openresizeioBytesIOsaveclosegetvaluer;   rH   rO   rN   )_image
_orig_size_w_h_ratio_w_ratio_h_img_img_resized_image_stream_image_datar5   s             r-   _resize_image&Splash.assemble.<locals>._resize_image3  s]   x#,,Q/"4a<R]+B**1-B,,Q/"4a<R]+B**1-B fhnn55!D#==0D#{{B84 !#

!!-!>

""$+446Mt`jprs"" N  ]JqM43D3DQ3GIZIZ[\I]^_ rA   rb   s   PNG

   z!I   r   r)moder   r   z Converted image %s to PNG formatz
The image z needs to be converted to a PNG file, but PIL.Image is not available! Either install the Pillow package, or use a PNG image for you splash screen.)r;   rH   r   r   rO   readseekstructunpackr   r8   r9   abspathr   sizer   r   r   r   r   rN   r   r4   r:   r[   r]   r   TK_ROOTNAMErY   )r5   r   rO   img_sizeimageimg
image_datas   `      r-   assembleSplash.assemble/  s   ($))4$	N $//40
 ??1!55OOBdJOOA,>?BFMMRVXbXgXghiXjDklmDnoH$+++%doox@8X--c:Cxx$+++%c884ZZ\
E2		"++-KK:DOOLOSa 
 	II$$GGT\\*GGT[[)""KK	
rA   c                     [         R                  n [         R                  n[        (       a   [         R                  (       a  [        S5      eU S:  d  US:  a  [        R                  " S/U QUQ76   X:w  a  [        R                  " S/U QUQ76   [         R                  (       d  [        S5      e[         R                  b  [         R                  c'  Sn[         R                  (       d  US-  n[        U5      eg )Nz[ERROR: The splash screen feature does not support macOS system framework version of Tcl/Tk.)r      zThe installed Tcl/Tk (%d.%d / %d.%d) version might not work with the splash screen feature of the bootloader, which was tested against Tcl/Tk 8.6zqThe installed version of Tcl (%d.%d) and Tk (%d.%d) do not match. PyInstaller is tested against matching versionszqERROR: The installed Tcl version is not threaded. PyInstaller only supports the splash screen using threaded Tcl.zjERROR: Could not determine the path to Tcl and/or Tk shared library, which are required for splash screen.z The _tkinter module appears to be a built-in, which likely means that python was built with statically-linked Tcl/Tk libraries and is incompatible with splash screen.)r   re   rf   r   is_macos_system_frameworkrF   r;   r<   tcl_threadedrZ   r\   rS   )re   rf   messages      r-   rI   "Splash._check_tcl_tk_compatibility  s     ,,**
9==m 
 :#6NNBDOR\ $NN$&14> &&&  ((0J4P4P4X8  44a W%% 5YrA   c           	      t   0 nU R                   bo  [        R                  S5        UR                  U R                   S   U R                   S   U R                  U R
                  U R                  U R                  S.5        [        R                  " XR                  S9nU R                  (       aI  SR                  S [        S	 UR                  5       5       5       5      n[        R                   " S
SU5      n[#        U R$                  SSS9 nUR'                  U5        SSS5        U$ ! , (       d  f       U$ = f)zn
Generate the script for the splash screen.

If minify_script is True, all unnecessary parts will be removed.
Nz!Add text support to splash screenr   r~   )pad_xpad_ycolorfont	font_sizedefault_text)text_optionsr&   
c              3   h   #    U  H(  nUR                  S 5      (       a  M  U(       d  M$  Uv   M*     g7f)#N)
startswith)r+   lines     r-   r.   )Splash.generate_script.<locals>.<genexpr>  s-      !Ts+  !Ts   22	2c                 "    U R                  5       $ )N)strip)r   s    r-   <lambda>(Splash.generate_script.<locals>.<lambda>  s
    $**,rA   z + wzutf-8)encoding)r   r;   rW   r`   r"   r    r   r$   r   build_scriptr&   r   rK   map
splitlinesresubr   r   write)r5   drY   script_files       r-   rX   Splash.generate_script  s    ==$LL<=HHq)q)!^^ $ 1 1  "..AM_M_`YY !$%>@Q@Q@S!T F VVD#v.F $""C':kf% ; ;:s   D((
D7c                     [         R                  " U 5      n U H"  u  p#n[         R                  " U5      U :X  d  M"    g   g)NTF)pathlibPurePath)tkinter_filerb   	dest_namerl   typecodes        r-   rU   Splash._uses_tkinter  s>     ''5-5)I)\9 .6 rA   )rT   r&   rb   r   rO   r   r   r   rY   r   r4   r[   r"   r$   r    r   r   r]   rV   N)__name__
__module____qualname____firstlineno____doc__rE   r   r   _GUTSrv   r   staticmethodrI   rX   rU   __static_attributes__r)   rA   r-   r   r   3   s    Mb 
~&	 	'	^$	n%	n%	~&	(	.)	N#	.)	(	(	>"	N#	>"	/	_% 
.)1E6	T
l *& *&X D  rA   r   )%r   r8   r   r   r   PyInstallerr   loggingPyInstaller.archive.writersr   PyInstaller.buildingr   PyInstaller.building.datastructr   PyInstaller.building.utilsr   r   r	   PyInstaller.compatr
   r   PyInstaller.dependr   PyInstaller.utils.hooks.tcl_tkr   PILr   r   ImportError	getLoggerr   r;   r9   rK   r   r4   r   r)   rA   r-   <module>r      s)   
 	 	   & 4 1 2 L L 0 ( 5% 
		8	$ GGLL''9GGLL''4GGLL''2GGLL''	:GGLL''<GGLL''>GGLL''<
 iV i/  Hs   E9 9FF