views:

155

answers:

3

Hello,

I have a Python application and I decided to do a .exe to execute it.

This is the code that I use to do the .exe:

# -*- coding: cp1252 -*-
from distutils.core import setup
import py2exe, sys, os

sys.argv.append('py2exe')


setup(
    options = {'py2exe': {'bundle_files': 1}},
    windows = [{'script': "SoundLog.py"}],
    zipfile = None,
    packages=[r"C:\Users\Public\SoundLog\Code\Código Python\SoundLog\Auxiliar", r"C:\Users\Public\SoundLog\Code\Código Python\SoundLog\Plugins"],
)

But when I run my application with the .exe, the graphics are quite different.

In the image bellow you can see the application running thought python at the left and running thought the .exe at the right. alt text

How can I make the .exe one be as good as the one that runs thought python?

+7  A: 

I assume you mean the visual style of the toolbar and buttons. You need to add a manifest file to the EXE file or as a separate file so that Windows applies the modern style of recent comctl32.dll versions.

Check out Using Windows XP Visual Styles With Controls on Windows Forms on MSDN. Read the relevant part about creating the ".exe.manifest" file.

A more py2exe-specific tutorial can be found over at the wxPython site. They explain how to use setup.py to include the necessary manifest file.

AndiDog
it was exactlly this :)
aF
A: 

I found that I didn't need the manifest file when I used Python 2.6 on Windows 7. But I did need it when I used Python 2.5 on XP and Vista. If you use GUI2Exe, all you need to do is check a little checkbox to include it.

See the following tutorials:

http://www.blog.pythonlibrary.org/2010/07/31/a-py2exe-tutorial-build-a-binary-series/

http://www.blog.pythonlibrary.org/2010/08/31/another-gui2exe-tutorial-build-a-binary-series/

There's also a Python-related manifest for anything 2.6+ due to the switch in compilers on Windows (i.e. VS2008 vs ye olde VS2003). Robin Dunn seems to have fixed the latest build of wxPython so you don't need to include that annoyance, but if you're NOT using wx, then you'll probably run into this issue when you try to create a binary. The py2exe website and the wxPython wiki both talk about the issue and how to create the SxS manifest.

Mike Driscoll
A: 

The final setup that I mounted was this:

# -*- coding: cp1252 -*-
from distutils.core import setup
import py2exe, sys, os
from glob import glob

sys.argv.append('py2exe')


manifest = """
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level='asInvoker' uiAccess='false' />
      </requestedPrivileges>
    </security>
  </trustInfo>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity
     type='win32'
     name='Microsoft.VC90.CRT'
     version='9.0.21022.8'
     processorArchitecture='*'
     publicKeyToken='1fc8b3b9a1e18e3b' />
    </dependentAssembly>
  </dependency>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity
         type="win32"
         name="Microsoft.Windows.Common-Controls"
         version="6.0.0.0"
         processorArchitecture="*"
         publicKeyToken="6595b64144ccf1df"
         language="*" />
    </dependentAssembly>
  </dependency>
</assembly>
"""

setup(
##    data_files = data_files,
    options = {'py2exe': {'bundle_files': 1}},
    windows = [{'script': "SoundLog.py", 'other_resources': [(24,1,manifest)]}],
    zipfile = None,
    packages=[r"C:\Users\Public\SoundLog\Code\Código Python\SoundLog\Auxiliar", r"C:\Users\Public\SoundLog\Code\Código Python\SoundLog\Plugins"],
)

Thanks for the quick answers :)

aF