[Python] pyinstaller 封裝簡易程式教學
安裝方法
pip install pyinstaller
打包 exe 指令(於CMD輸入)
pyinstaller -F 文件名.py
設定程式圖標方法
pyinstaller -F 文件名.py -i=圖標文件名.ico
如需設定版本信息,可以使用 pyi-set_version 功能
指令為
pyi-set_version 版本信息文件名.txt 程式文件名.exe
版本信息範本
# UTF-8 # # For more details about fixed file info 'ffi' see: # http://msdn.microsoft.com/en-us/library/ms646997.aspx VSVersionInfo( ffi=FixedFileInfo( # filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4) # Set not needed items to zero 0. filevers=(1, 0, 0, 0), prodvers=(1, 0, 0, 0), # Contains a bitmask that specifies the valid bits 'flags'r mask=0x3f, # Contains a bitmask that specifies the Boolean attributes of the file. flags=0x0, # The operating system for which this file was designed. # 0x4 - NT and there is no need to change it. OS=0x40004, # The general type of file. # 0x1 - the file is an application. fileType=0x1, # The function of the file. # 0x0 - the function is not defined for this fileType subtype=0x0, # Creation date and time stamp. date=(0, 0) ), kids=[ StringFileInfo( [ StringTable( u'040904E4', [StringStruct(u'CompanyName', u''), StringStruct(u'FileDescription', u'Program'), StringStruct(u'FileVersion', u'1.0.0.0'), StringStruct(u'LegalCopyright', u'Copyright (C) 2021 Yin92. All Rights Reserved'), StringStruct(u'ProductName', u'Program'), StringStruct(u'ProductVersion', u'1.0.0.0')]) ]), VarFileInfo([VarStruct(u'Translation', [1033, 1200])]) ] )
程式語言 Translation 項目(範例檔設定值為: 1033, 1200)請參考以下網站:
https://docs.microsoft.com/en-us/windows/win32/menurc/varfileinfo-block
將 0x 後數值用 Hex to Decimal Converter 轉換即可得出需要數值
以英文為例 0x0409 的 0409 轉換後即為 1033
近期留言