我正在使用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或其他东西的界面。这是图像:
答案 0 :(得分:2)
我也遇到了这个问题并找到了解决办法 要让Windows控件看起来正常,首先必须将清单插入目标可执行文件,就像here提到的那样。
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并安装,然后输入已安装的文件夹,使用Manifest View从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运行得很好。
答案 1 :(得分:0)
这个脚本适合我:
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,
)
也许你可以试试这是否适合你。因为'w9xpopen.exe'
只需要旧版本
Windows系统,即Windows 95和98,您可以添加
'dll_excludes': ['w9xpopen.exe']
。这可能有助于解决您的问题。