简体   繁体   English

wxPython-py2exe-exe文件旧窗口

[英]wxPython - py2exe - exe file old window

I'm using py2exe to convert my GUI application made using wxPython to a standalone single exe file. 我正在使用py2exe将使用wxPython制作的GUI应用程序转换为独立的单个exe文件。 This is what i'm using in setup.py: 这是我在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']
)

Everything goes well, but the problem I'm facing is that the UI looks old. 一切进展顺利,但我面临的问题是UI看起来很旧。 It's like the interface of Windows 97 or something. 就像Windows 97的界面一样。 Here's the image: 这是图片:

截图

I have also encountered this problem and found a solution. 我也遇到了这个问题,并找到了解决方案。
To let windows controls looks normal, first you MUST insert manifest to the target executable file, just as here mentions. 为了使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"]
)

Second, you MUST get the corresponding run-time dlls. 其次,您必须获取相应的运行时dll。
To get manifest and dlls, you could download Dropbox and install, and enter the installed folder, use Manifest View to get manifest from Dropbox.exe and dlls from sub-folder Microsoft.VC90.CRT (Keep this folder in your app dist). 要获取清单和dll,您可以下载Dropbox并安装,然后输入已安装的文件夹,使用清单视图从Dropbox.exe获取清单,并从子文件夹Microsoft.VC90.CRT获取dll(将文件夹保留在应用程序dist中)。 The following is what I have gotten from Dropbox.exe. 以下是我从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>

Then the target exe runs very well. 然后目标exe运行得很好。

This script works for me: 该脚本对我有用:

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,
    )

Maybe you can try if this works for you. 也许您可以尝试一下是否适合您。 Since 'w9xpopen.exe' is only needed for old Windows systems, ie Windows 95 and 98, you can add 'dll_excludes': ['w9xpopen.exe'] . 由于仅在旧的Windows系统(即Windows 95和98)中才需要'w9xpopen.exe' ,因此您可以添加'dll_excludes': ['w9xpopen.exe'] This might help to solve your problem. 这可能有助于解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM