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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
U
W±d&\ã @sBddlZddlZddlZddlZddlZddlmZddlm    Z    ddl
m Z ddl m Z ddlmZmZmZddlmZmZmZddlmZzdd    lmZWnek
r´dZYnXe e¡Zej  !ej"d
¡ej  !ej"d ¡ej  !ej"d ¡ej  !ej"d d¡ej  !ej"d d¡ej  !ej"d d¡ej  !ej"d d¡gZ#Gdd„de ƒZ$dS)éN)Úlog)Ú SplashWriter)Úsplash_templates)ÚTarget)Ú_check_guts_eqÚ_check_guts_tocÚmisc)Ú    is_darwinÚis_winÚ    is_cygwin)Útcl_tk)ÚImagez license.termsztext.tclztk.tclÚttkzttk.tclz    fonts.tclz cursors.tclz    utils.tclc@sÌeZdZdZdd„Zdefdefdefdefdefd    efd
efd efd efd efdefdefdefdefdefdefdefdefdefdeffZdd„Zdd„Z    dd„Z
dd„Z e d d!„ƒZ e d"d#„ƒZd$S)%Ú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
 s‚ddlm}t ˆ¡tr"tdƒ‚tj |¡s@tj     |d|¡}tj 
|¡}tj  |¡sdt d|ƒ‚|ˆ_ | dd¡ˆ_| dd    ¡ˆ_| d
d    ¡ˆ_| d d ¡ˆ_| d d    ¡ˆ_| dd¡ˆ_| dd    ¡ˆ_| dd¡ˆ_| dd¡ˆ_| dd¡ˆ_| dd¡ˆ_| dd ¡ˆ_tj ˆj¡d}ˆjd    kr:|dˆ_ˆjd    krP|dˆ_ˆjd    krlˆ ||¡ˆ_zdd    l}|ˆ_ˆjj ˆ_!Wnt"k
r¦tdƒ‚YnXˆ #ˆj!|¡ˆ_$t% &dˆj$¡ˆ '¡ˆ_(t) *ˆj!¡\ˆ_+ˆ_,trˆj+dd    ks
d ˆj+dkrtd!ƒ‚t-ˆj+ƒs"t.‚t-ˆj,ƒs2t.‚t% &d"ˆj+ˆj,¡t/ˆj+dˆj,dgt0ƒˆ_0t% 1d#¡t) 2ˆj!¡}ˆjr–ˆj0 3d$d%„|Dƒ¡gˆ_4ˆj$súˆj4 5ˆj+dˆj+dd&f¡ˆj4 5ˆj,dˆj,dd&f¡ˆj4 6‡fd'd%„|Dƒ¡t7st8r&d(h‰ˆj0 3‡fd)d*„|Dƒ¡t/d+d%„||ˆj4Dƒƒ‰‡fd,d-„}    t/t9|    ˆj0ƒƒˆ_0ˆ :¡t% &d.ˆj0¡ˆ ;¡d    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 rundir:
            The folder name in which tcl/tk will be extracted at runtime. There should be no matching folder in your
            application to avoid conflicts. Default:  ``'__splash'``
        :type rundir: str
        :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(Splash screen is not supported on macOS.ZspecpathzImage file '%s' not foundÚfull_tkFÚnameNÚ script_nameÚ minify_scriptTÚrundirÚ max_img_size)iøiàÚtext_posÚ    text_sizeé Ú    text_fontZ TkDefaultFontÚ
text_colorZblackÚ text_defaultZ InitializingÚ always_on_toprz.resz _script.tclz~You platform does not support the splash screen feature, since tkinter is not installed. Please install tkinter and try again.zProgram uses tkinter: %réz Library/Frameworks/Tcl.frameworkzTThe splash screen feature does not support macOS system framework version of Tcl/Tk.z&Use Tcl Library from %s and Tk From %sz-Collect tcl/tk binaries for the splash screencss|]}|dVqdS©rN©©Ú.0Úentryr!r!úRd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\PyInstaller/building/splash.pyÚ    <genexpr>Òsz"Splash.__init__.<locals>.<genexpr>ÚBINARYc3s |]}|dˆjkr|VqdSr )Úsplash_requirementsr"©Úselfr!r%r&Ýszvcruntime140.dllcs g|]^}}| ¡ˆkr|‘qSr!)Úlower)r#rÚ_)ÚEXTRA_REQUIREMENTSr!r%Ú
<listcomp>ïs z#Splash.__init__.<locals>.<listcomp>css|]}|dVqdSr r!r"r!r!r%r&òscs|ˆkrt d|¡dSdS)Nz†The local Tcl/Tk installation is missing the file %s. The behavior of the splash screen is therefore undefined and may be unsupported.FT)ÚloggerÚwarning)Úfilename)Úcollected_filesr!r%Ú_filter_requirementôsþz,Splash.__init__.<locals>._filter_requirementzSplash Requirements: %s)<ÚconfigrrÚ__init__r    Ú
SystemExitÚosÚpathÚisabsÚjoinÚnormpathÚexistsÚ
ValueErrorÚ
image_fileÚgetrrrrrrrrrrrrÚsplitextZ tocfilenameÚ _find_rundirÚ_tkinterÚ_tkinter_moduleÚ__file__Ú _tkinter_fileÚModuleNotFoundErrorÚ _uses_tkinterÚ uses_tkinterr/ÚdebugÚgenerate_scriptÚscriptÚ tcltk_utilsZfind_tcl_tk_shared_libsÚtcl_libÚtk_libÚallÚAssertionErrorÚsetr(ÚinfoZcollect_tcl_tk_filesÚupdateÚbinariesÚappendÚextendr
r ÚfilterÚtest_tk_versionZ __postinit__)
r*r>rTZdatasÚkwargsrÚrootrBZ
tcltk_treer3r!)r-r2r*r%r59s„I 
 
 
 ÿ
 
 
   zSplash.__init__r>rrrrrrrrrrrrrHrKrMrNr(rTrEcCs<t |||¡rdSt |j¡|kr8t d|j|j¡dSdS)NTz#Building %s because file %s changedF)rÚ _check_gutsrÚmtimer>r/rRZ tocbasename)r*ÚdataZ
last_buildr!r!r%r[%s zSplash._check_gutsc    s:t dˆj¡‡fdd„}tˆjdƒ}| d¡dkr’| d¡t d| d    ¡¡d
t d| d    ¡¡d
f}|ˆj    kr‚|ˆj|ƒ}nt
j   ˆj¡}npt röt jˆjd d }|jˆj    krÀ|||jƒ}n&t ¡}|j|d d| ¡| ¡}t dˆj¡n tdˆjƒ‚| ¡tˆjˆjˆjd
ˆjd
tjˆj|ˆjƒdS)NzBuilding Splash %sc
strØ|\}}ˆjd|}|dkr8t||ƒ}ˆjd}ˆjd|}|dkrdt||ƒ}ˆjd}t|tjƒrv|}n
t |¡}| ||f¡}t ¡}|j    |dd| 
¡| 
¡|  ¡}    t   dˆjt|ƒ||¡|    Std|d|dˆjdˆjdƒ‚dS)NrrÚPNG©Úformatz/Resized image %s from dimensions %s to (%d, %d)zíThe 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/rRr>Ústrr=)
Z_imageZ
_orig_sizeÚ_wZ_hZ_ratio_wZ_ratio_hZ_imgZ _img_resizedZ _image_streamZ _image_datar)r!r%Ú _resize_image4s8 
 
 
üz&Splash.assemble.<locals>._resize_imageÚrbés‰PNG
 
éz!IérÚr)Úmoder^r_z Converted image %s to PNG formatzžThe image %s 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/rRrrdr>ÚreadÚseekÚstructÚunpackrr7r8ÚabspathraÚsizerfrgrhrirjr=rr(rMrNrLÚ TK_ROOTNAMErrK)r*rmr>Zimg_sizeÚimageÚimgZ
image_datar!r)r%Úassemble0sB ' 
,
 þøzSplash.assemblecCsnt|jjƒ}t|jjƒ}|dks(|dkr>t d|jj|jj¡||kr\t d|jj|jj¡tjsjtdƒ‚dS)Ng333333!@z‘The installed Tcl/Tk (%s/%s) version might not work with the splash screen feature of the bootloader. The bootloader is tested against Tcl/Tk 8.6zkThe installed version of Tcl (%s) and Tk (%s) do not match. PyInstaller is tested against matching versionszjThe installed tcl version is not threaded. PyInstaller only supports the splash screen using threaded tcl.)    ÚfloatrCZ TCL_VERSIONZ
TK_VERSIONr/r0rLZ tcl_threadedr6)r*Z tcl_versionZ
tk_versionr!r!r%rX‡s$  ýþÿzSplash.test_tk_versionc    Cs°i}|jdk    rDt d¡| |jd|jd|j|j|j|jdœ¡tj    ||j
d}|j rŠd  dd    „t d
d „| ¡ƒDƒ¡}t d d |¡}t|jdƒ}| |¡W5QRX|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 screenrr)Zpad_xZpad_yÚcolorÚfontZ    font_sizeZ default_text)Z text_optionsrÚ
css |]}| d¡s|r|VqdS)ú#N)Ú
startswith)r#Úliner!r!r%r&·s
þz)Splash.generate_script.<locals>.<genexpr>cSs| ¡S)N)Ústrip)r„r!r!r%Ú<lambda>¸óz(Splash.generate_script.<locals>.<lambda>z +ú Úw)rr/rIrSrrrrrZ build_scriptrrr:ÚmapÚ
splitlinesÚreÚsubrdrÚwrite)r*ÚdrKZ script_filer!r!r%rJ¢s(
 
ú
ÿzSplash.generate_scriptcCs2t |¡}|D]\}}}t |¡|krdSqdS)NTF)ÚpathlibÚPurePath)Z tkinter_filerTZ    dest_nameÚsrc_nameÚtypecoder!r!r%rGÄs
 
zSplash._uses_tkintercsPd}|d‰d}t‡fdd„|DƒƒrL|t|ƒ‰|d7}tˆƒdkst‚qˆS)Nz
__splash%sÚrc3s"|]}|d ˆtj¡VqdSr )rƒr7Úsep)r#Úe©Ú    candidater!r%r&×sz&Splash._find_rundir.<locals>.<genexpr>rrp)ÚanyrkÚlenrP)Z    structurerÚcounterr!r—r%rAÎs zSplash._find_rundirN)Ú__name__Ú
__module__Ú __qualname__Ú__doc__r5rrZ_GUTSr[r}rXrJÚ staticmethodrGrAr!r!r!r%r2s@Sç W"
    r)%rfr7rŒrvrZ PyInstallerrÚloggingZPyInstaller.archive.writersrZPyInstaller.buildingrZPyInstaller.building.datastructrZPyInstaller.building.utilsrrrZPyInstaller.compatr    r
r ZPyInstaller.utils.hooksr rLZPILr raÚ ImportErrorÚ    getLoggerrœr/r8r:rzr(rr!r!r!r%Ú<module> s2     
 
    ÷