[英]wxPython - py2exe - exe file old window
我正在使用py2exe将使用wxPython制作的GUI应用程序转换为独立的单个exe文件。 这是我在setup.py中使用的:
from distutils.core import setup
import py2exe
includes = []
excludes = ['_gtkagg', '_tkagg', 'bsddb', 'curses', 'email', 'pywin.debugger',
'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl',
'Tkconstants', 'Tkinter']
packages = []
dll_excludes = ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll', 'tcl84.dll',
'tk84.dll']
setup(
options = {"py2exe": {"compressed": True,
"optimize": 2,
"includes": includes,
"excludes": excludes,
"packages": packages,
"dll_excludes": dll_excludes,
"bundle_files": 1,
"dist_dir": "dist",
"skip_archive": False,
"ascii": False,
"custom_boot_script": '',
}
},
zipfile = None,
windows=['script.py']
)
一切进展顺利,但我面临的问题是UI看起来很旧。 就像Windows 97的界面一样。 这是图片:
我也遇到了这个问题,并找到了解决方案。
为了使Windows控件看起来正常,首先,您必须将清单文件插入目标可执行文件,如此处所述 。
manifest = """
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0">
<assemblyIdentity
version="0.64.1.0"
processorArchitecture="x86"
name="Controls"
type="win32"
/>
<description>Your Application</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
"""
setup(
windows = [
{
"script": "yourapplication.py",
"icon_resources": [(1, "yourapplication.ico")],
"other_resources": [(24,1,manifest)]
}
],
data_files=["yourapplication.ico"]
)
其次,您必须获取相应的运行时dll。
要获取清单和dll,您可以下载Dropbox并安装,然后输入已安装的文件夹,使用清单视图从Dropbox.exe获取清单,并从子文件夹Microsoft.VC90.CRT获取dll(将文件夹保留在应用程序dist中)。 以下是我从Dropbox.exe获得的内容。
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<asmv3:windowsSettings
xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
<assemblyIdentity
version="2.6.25.0"
processorArchitecture="X86"
name="Dropbox"
type="win32"
/>
<description>*</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.VC90.CRT"
version="9.0.30729.1"
processorArchitecture="x86"
publicKeyToken="1fc8b3b9a1e18e3b"
/>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
然后目标exe运行得很好。
该脚本对我有用:
from distutils.core import setup
import py2exe
setup(
options = {'py2exe': {'bundle_files': 1,
'dll_excludes': ['w9xpopen.exe'],
'excludes': ['pywin', 'pywin.debugger',
'pywin.debugger.dbgcon',
'pywin.dialogs',
'pywin.dialogs.list',
'Tkconstants', 'Tkinter', 'tcl']}},
windows = [{'script': 'script.py'}],
zipfile = None,
)
也许您可以尝试一下是否适合您。 由于仅在旧的Windows系统(即Windows 95和98)中才需要'w9xpopen.exe'
,因此您可以添加'dll_excludes': ['w9xpopen.exe']
。 这可能有助于解决您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.