I packed a Python script (that uses pyGTK) into an .exe with py2exe. It runs fine, except that the normal GTK theme does not show up. This is what it looks like when I run the script:

http://img33.imageshack.us/img33/4080/16sepwed1827.png

And this is what it looks like when I run the .exe from the "dist" directory:

http://img198.imageshack.us/img198/4616/16sepwed1826.png

I read that, to provide necessary GTK themes and other data, you need to copy the etc, lib, and share directories from the GTK runtime folder into the dist directory. I tried that, but I get the same result. No normal theme.

I'm running the program in a Windows 7 VM.

Also, here is my setup.py:

from distutils.core import setup
import py2exe, sys, os

sys.argv.append('py2exe')

setup(
    options = {'py2exe': {'bundle_files': 1, 'includes': 'cairo, pango, pangocairo, atk, gobject'}},
    windows = [{'script': "countdowntimer.py"}],
    data_files = [('.', ['countdowntimer.xml'])],
    zipfile = None,
)

With wxPython code you can give py2exe an XML based manifest to force it to adopt the Windows XP theme.

Yes, the native drawing of widgets on all platforms is indeed wxWidgets' strongest point, but I didn't write my GUI in wxWidgets, nor do I want to.

Any ideas guys? I've been googling some more and nobody else seems to have this problem. All of them simply say to copy the GTK etc, lib, and share directories (that have the themes) into the dist directory, but this doesn't do anything for me.

Have you tried andrea gavana's gui2exe? It have many options that comes from py2exe. It have also other 'packers' options.
Check if it can solve your problem

www.code.google.com/p/gui2exe/

Thanks for the response. I just tried to run a setup.py generated by GUI2Exe and it is throwing an exception when trying to include python26.dll.

Adding python26.dll as resource to C:\Users\John\Desktop\dist\testapp.exe

Traceback (most recent call last):
  File "setup2.py", line 159, in <module>
    windows = [GUI2Exe_Target_1]
  File "C:\Python26\lib\distutils\core.py", line 152, in setup
    dist.run_commands()
  File "C:\Python26\lib\distutils\dist.py", line 975, in run_commands
    self.run_command(cmd)
  File "C:\Python26\lib\distutils\dist.py", line 995, in run_command
    cmd_obj.run()
  File "C:\Python26\lib\site-packages\py2exe\build_exe.py", line 243, in run
    self._run()
  File "C:\Python26\lib\site-packages\py2exe\build_exe.py", line 312, in _run
    self.create_binaries(py_files, extensions, dlls)
  File "C:\Python26\lib\site-packages\py2exe\build_exe.py", line 572, in create_binaries
    arcname, target.script)
  File "C:\Python26\lib\site-packages\py2exe\build_exe.py", line 908, in build_executable
    add_resource(ensure_unicode(exe_path), data, res_type, res_id, False)
RuntimeError: EndUpdateResource: The system cannot open the device or file specified.

I found out how to solve this problem! First, I had to change:

'bundle_files': 1

to

'bundle_files': 3

Then, when the build was complete, I pasted the GTK directories etc, lib, and share into the dist folder. My application now uses native widgets.

do us a favor and mark it solved :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.