当前位置:Gxlcms > mysql > Py2exe打包后图标不显示

Py2exe打包后图标不显示

时间:2021-07-01 10:21:17 帮助过:61人阅读

下载Png2Ico http://www.winterdrache.de/freeware/png2ico/ 编辑图标大小准备 248*248 128*128 64*64 48*48 32*32 16*16的图标 命令下执行 Png2Icon.exe Attach.ico logo248.png logo128.png,logo64.png logo48.png logo32.png logo16.png 生成Ico文件 这样

下载Png2Ico

http://www.winterdrache.de/freeware/png2ico/

编辑图标大小准备 248*248 128*128 64*64 48*48 32*32 16*16的图标

命令下执行 Png2Icon.exe Attach.ico logo248.png logo128.png,logo64.png logo48.png logo32.png logo16.png

生成Ico文件 这样就能适应win7下面的大小了。

如果程序需要管理员身份运行,在mainfest中 添加

  1. <trustinfo xmlns="urn:schemas-microsoft-com:asm.v3">
  2. <security>
  3. <requestedprivileges>
  4. <requestedexecutionlevel level="requireAdministrator" uiaccess="false">
  5. </requestedexecutionlevel></requestedprivileges>
  6. </security>
  7. </trustinfo>

下面是我的完整打包代码

注意修改版本号为version="9.0.21022.8"

  1. # -*- coding:gbk -*-
  2. from distutils.core import setup
  3. from glob import glob
  4. try:
  5. # py2exe 0.6.4 introduced a replacement modulefinder.
  6. # This means we have to add package paths there, not to the built-in
  7. # one. If this new modulefinder gets integrated into Python, then
  8. # we might be able to revert this some day.
  9. # if this doesn't work, try import modulefinder
  10. try:
  11. import py2exe.mf as modulefinder
  12. except ImportError:
  13. import modulefinder
  14. import win32com, sys
  15. for p in win32com.__path__[1:]:
  16. modulefinder.AddPackagePath("win32com", p)
  17. for extra in ["win32com.shell"]: #,"win32com.mapi"
  18. __import__(extra)
  19. m = sys.modules[extra]
  20. for p in m.__path__[1:]:
  21. modulefinder.AddPackagePath(extra, p)
  22. except ImportError:
  23. # no build path setup, no worries.
  24. pass
  25. manifest = """
  26. <!--?xml version="1.0" encoding="UTF-8" standalone="yes"?-->
  27. <noinheritable></noinheritable>
  28. <file name="msvcr90.dll" hashalg="SHA1" hash="9785b1c493deb5b2134dc4aef3719cee207001bc">
  29. <dsig:transforms><dsig:transform algorithm="urn:schemas-microsoft-com:HashTransforms.Identity">
  30. </dsig:transform></dsig:transforms><dsig:digestmethod algorithm="http://www.w3.org/2000/09/xmldsig#sha1">
  31. </dsig:digestmethod><dsig:digestvalue>VF5ECUAHPV7EnUf+/UIXMPizPvs=</dsig:digestvalue>
  32. </file>
  33. <file name="msvcp90.dll" hashalg="SHA1" hash="0f6bbf7fe4fb3fca2cb5b542eca1a1cad051f01c">
  34. <dsig:transforms><dsig:transform algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:transform>
  35. </dsig:transforms><dsig:digestmethod algorithm="http://www.w3.org/2000/09/xmldsig#sha1">
  36. </dsig:digestmethod><dsig:digestvalue>3Wg+StVMq2uhx7POnAkl2w4dDmY=</dsig:digestvalue>
  37. </file>
  38. <file name="msvcm90.dll" hashalg="SHA1" hash="7f3290ab2b7444c2b4a9b1fedfdb16466d7a21bb">
  39. <dsig:transforms><dsig:transform algorithm="urn:schemas-microsoft-com:HashTransforms.Identity">
  40. </dsig:transform>
  41. </dsig:transforms>
  42. <dsig:digestmethod algorithm="http://www.w3.org/2000/09/xmldsig#sha1">
  43. </dsig:digestmethod><dsig:digestvalue>/YfRn7UQENzdMeoMHxTgdRMiObA=</dsig:digestvalue>
  44. </file>
  45. <description>ETimes SafeDocument </description>
  46. <dependency>
  47. <dependentassembly>
  48. </dependentassembly>
  49. </dependency>
  50. <trustinfo xmlns="urn:schemas-microsoft-com:asm.v3">
  51. <security>
  52. <requestedprivileges>
  53. <requestedexecutionlevel level="requireAdministrator" uiaccess="false">
  54. </requestedexecutionlevel></requestedprivileges>
  55. </security>
  56. </trustinfo>
  57. """
  58. data_files = [("Microsoft.VC90.CRT",
  59. glob(r'C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*.*'))]
  60. py2exe_options = {"py2exe": {
  61. "compressed": 1,
  62. "optimize": 0,
  63. "bundle_files": 1,
  64. "dll_excludes": ["mswsock.dll", "powrprof.dll"],
  65. "excludes": ["email", "System", "clr"],
  66. "typelibs": [("{A435DD76-804E-4475-8FAB-986EACD1C6BE}", 0x0, 1, 0), ]
  67. }
  68. }
  69. setup(
  70. data_files=data_files,
  71. windows=[{
  72. 'script': 'EtimesDocument.pyw',
  73. "other_resources":[(24,1,manifest)],
  74. "icon_resources": [
  75. (0, './png/Attach.ico')
  76. ]}],
  77. zipfile='core.lib',
  78. options=py2exe_options
  79. )

人气教程排行