;iZ ddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Z ddlmZmZmZddlmZmZddlmZdd lmZ dd lmZn #e$rdZYnwxYwejeZej !ej"d ej !ej"d ej !ej"d ej !ej"ddej !ej"ddej !ej"ddej !ej"ddgZ#Gdde Z$dS)N)log) SplashWriter)splash_templates)Target)_check_guts_eq_check_guts_tocmisc)is_aix is_darwin) bindepend) tcltk_info)Image license.termsztext.tclztk.tclttkzttk.tclz fonts.tclz cursors.tclz utils.tclceZdZdZdZdefdefdefdefdefdefd efd efd efd efd efdefdefdefdefdefdefdefdeffZdZdZ e dZ dZ e dZ dS)Splasha 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 ddlm}tjtrt dt jst dt d tj |s&tj |d|}tj |}tj |st#d|z|_|dd _|d d _|d d _|d d_|dd_|dd _|dd_|dd_|dd_|dd_|dd_tj j d}j |dz_j |dz_t j!_"#j"|_$t%dj$&_'t j(_)t j*_+j)Jj+Jt%dj)t%d j+tYtj -j)tj -j+gt\_.t d!t j/}jr$j.0d"|Dd#j)j+fD}tcj2|_3j.0d$j3Dj$s&j34fd%|DtYd&||zj3zDfd'} tYtk| j._.t%d(j.tlrtj j)\} } | d)kr&t j7\} } xj)d*| d+| d,z c_)tj j+\} } | d)kr&t j8\}}xj+d-|d+|d,z c_+9d S).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 requirementsspecpathzImage file '%s' not foundfull_tkFnameN script_name minify_scriptT max_img_size)iitext_pos text_size text_font TkDefaultFont text_colorblack text_default Initializing always_on_toprz.resz _script.tclzProgram uses tkinter: %rzUsing Tcl shared library: %rzUsing Tk shared library: %rz/Collect Tcl/Tk data files for the splash screenc3&K|] }|dV dSrN.0entrys OC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\PyInstaller/building/splash.py z"Splash.__init__..s&+M+ME!H+M+M+M+M+M+McRg|]$}tj||df%S)BINARY)ospathbasename)r*src_names r, z#Splash.__init__..s/sss8rw''118XFsssr.c3&K|] }|dV dSr'r(r)s r,r-z"Splash.__init__..s&'L'LUa'L'L'L'L'L'Lr.c3:K|]}|djv|VdSr')splash_requirements)r*r+selfs r,r-z"Splash.__init__..s4 g g5%(dNfBfBfBfBfBfBf g gr.c3&K|] }|dV dSr'r(r)s r,r-z"Splash.__init__..s&WW5eAhWWWWWWr.c|vrBtj|dkrdStd|dSdS)NrFzThe local Tcl/Tk installation is missing the file %s. The behavior of the splash screen is therefore undefined and may be unsupported.T)r1r2r3loggerwarning)filenamecollected_filess r,_filter_requirementz,Splash.__init__.._filter_requirements[..7##H--@@ 5BCKu4r.zSplash Requirements: %sz.az (libtcl.so..)z (libtk.so.):configrr__init__r SystemExitr availabler<info_check_tcl_tk_compatibilityr1r2isabsjoinnormpathexists ValueError image_filegetrrrrrrrrr!r#r%splitext tocfilenametkinter_extension_file _tkinter_file _uses_tkinter uses_tkinterdebuggenerate_scriptscripttcl_shared_librarytcl_libtk_shared_librarytk_libsetr3r8 data_filesupdater binary_dependency_analysisbinariesextendfilterr tcl_version tk_version __postinit__)r9rNradataskwargsrroot tcltk_tree tcltk_libsr@_ext tcl_major tcl_minortk_majortk_minorr?s` @r,rDzSplash.__init__:spJ "!!!!!  PNOO O# 8   TUUU ((***w}}Z(( Dd:&6 CCJW%%j11 w~~j)) G8:EFF F%zz)U33 JJvt,, !::mT::#ZZ>>"JJ~zBB :t44 K44KAA **\7;;"JJ~~FF$ZZ>>w 011!4 9 v DI   ##m3D (>!..t/A8LL /1BCCC**,, !4  2 |'''{&&& 3T\BBB 2DK@@@#& G  T\ * * G  T[ ) ) ( ! ( $ $    EFFF* < N  $ + ++M+M*+M+M+M M M MtsX\XdfjfqWrsss !._resize_image3s# #B,Q/"4a<<R(]++B*1-B,Q/"4a<<R(]++B*1-Bfhn551!DD#=00D#{{B844 !# !!-!>>> ""$$$+4466  Mt`jlnprsss"" N ]JqM43DQ3GIZ[\I]^_r.rbsPNG  z!Irr)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<rGrrrNreadseekstructunpackrr1r2abspathr~sizerrrrrrMrr8r3rZr\r TK_ROOTNAMErX)r9rrNimg_sizeimageimg image_datas` r,assemblezSplash.assemble/s) ($)444$ $ $ $ $ N$/400  ??1  !5 5 5 OOB    dJOOA,>,>??BFMRVXbXgXghiXjXjDkDklmDnoH$+++% dox@@88  -c:::Cx$+++% c3844Z\\ E222 "++-- KK:DO L L L L*OSa   I  $ G  T\ * * G  T[ ) )  "  K     r.ctj}tj}trtjrt d|dks|dkrt jdg||R||krt jdg||Rtjst dtj tj "d}tj s|dz }t |dS)Nz[ERROR: The splash screen feature does not support macOS system framework version of Tcl/Tk.)rzThe 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 rdrer is_macos_system_frameworkrEr<r= tcl_threadedrYr[rR)rdremessages r,rHz"Splash._check_tcl_tk_compatibilitys1 , *  = m    :#6#6 NB DO R\     * $ $ N$ &1 4>     & &   ( 0J4P4X8 4 aW%% %5Y4Xr.c Pi}|j`td||jd|jd|j|j|j|jdtj ||j }|j rVd dtd |D}tjd d |}t#|jd d 5}||dddn #1swxYwY|S)z Generate the script for the splash screen. If minify_script is True, all unnecessary parts will be removed. Nz!Add text support to splash screenrrz)pad_xpad_ycolorfont font_size default_text) text_optionsr% c3HK|]}|d||VdS)#N) startswith)r*lines r,r-z)Splash.generate_script..sRs++r.c*|S)N)strip)rs r,z(Splash.generate_script..s$**,,r.z + wzutf-8)encoding)rr<rVr_r!rrr#r build_scriptr%rrJmap splitlinesresubrrwrite)r9drX script_files r,rWzSplash.generate_scriptsu  = $ LL< = = = HHq)q)!^ $ 1    ".ATM_```   /YY!$%>%>@Q@Q@S@S!T!TF VD#v..F$"C' : : : &k   f % % % & & & & & & & & & & & & & & & s9DD"Dcvtj|}|D]!\}}}tj||krdS"dS)NTF)pathlibPurePath) tkinter_filera dest_namer4typecodes r,rTzSplash._uses_tkintersQ' 55 -5   )Ix))\99tt:ur.N)__name__ __module__ __qualname____doc__rDrr_GUTSrsr staticmethodrHrWrTr(r.r,rr3s= MMMb ~&  ' ^$ n% n% ~& ( .) N# .) ( ( >" N# >" / _% .)1 E6   T T T l*&*&\*&X   D\r.r)%rr1rrr PyInstallerrloggingPyInstaller.archive.writersrPyInstaller.buildingrPyInstaller.building.datastructrPyInstaller.building.utilsrrr PyInstaller.compatr r PyInstaller.dependr PyInstaller.utils.hooks.tcl_tkr PILrr~ ImportError getLoggerrr<r2rJrr8rr(r.r,rs &&&&&&444444111111222222LLLLLLLLLL00000000((((((555555%%%%%%%HHH  8 $ $GLL'99GLL'44GLL'22GLL' ::GLL' <<GLL' >>GLL' << iiiiiViiiiis AAA