Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6745739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:14:26+00:00 2026-05-26T12:14:26+00:00

I’m using Python 2.6 and PyGTK 2.22.6 from the all-in-one installer on Windows XP,

  • 0

I’m using Python 2.6 and PyGTK 2.22.6 from the all-in-one installer on Windows XP, trying to build a single-file executable (via py2exe) for my app.

My problem is that when I run my app as a script (ie. not built into an .exe file, just as a loose collection of .py files), it uses the native-looking Windows theme, but when I run the built exe I see the default GTK theme.

I know that this problem can be fixed by copying a bunch of files into the dist directory created by py2exe, but everything I’ve read involves manually copying the data, whereas I want this to be an automatic part of the build process. Furthermore, everything on the topic (including the FAQ) is out of date – PyGTK now keeps its files in C:\Python2x\Lib\site-packages\gtk-2.0\runtime\..., and just copying the lib and etc directories doesn’t fix the problem.

My questions are:

  1. I’d like to be able to programmatically find the GTK runtime data in setup.py rather than hard coding paths. How do I do this?

  2. What are the minimal resources I need to include?

Update: I may have almost answered #2 by trial-and-error. For the “wimp” (ie. MS Windows) theme to work, I need the files from:

runtime\lib\gtk-2.0\2.10.0\engines\libwimp.dll
runtime\etc\gtk-2.0\gtkrc
runtime\share\icons\*
runtime\share\themes\MS-Windows

…without the runtime prefix, but otherwise with the same directory structure, sitting directly in the dist directory produced by py2exe. But where does the 2.10.0 come from, given that gtk.gtk_version is (2,22,0)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:14:26+00:00Added an answer on May 26, 2026 at 12:14 pm

    Answering my own question here, but if anyone knows better feel free to answer too. Some of it seems quite fragile (eg. version numbers in paths), so comment or edit if you know a better way.

    1. Finding the files

    Firstly, I use this code to actually find the root of the GTK runtime. This is very specific to how you install the runtime, though, and could probably be improved with a number of checks for common locations:

    #gtk file inclusion
    import gtk
    # The runtime dir is in the same directory as the module:
    GTK_RUNTIME_DIR = os.path.join(
        os.path.split(os.path.dirname(gtk.__file__))[0], "runtime")
    
    assert os.path.exists(GTK_RUNTIME_DIR), "Cannot find GTK runtime data"
    

    2. What files to include

    This depends on (a) how much of a concern size is, and (b) the context of your application’s deployment. By that I mean, are you deploying it to the whole wide world where anyone can have an arbitrary locale setting, or is it just for internal corporate use where you don’t need translated stock strings?

    If you want Windows theming, you’ll need to include:

    GTK_THEME_DEFAULT = os.path.join("share", "themes", "Default")
    GTK_THEME_WINDOWS = os.path.join("share", "themes", "MS-Windows")
    GTK_GTKRC_DIR = os.path.join("etc", "gtk-2.0")
    GTK_GTKRC = "gtkrc"
    GTK_WIMP_DIR = os.path.join("lib", "gtk-2.0", "2.10.0", "engines")
    GTK_WIMP_DLL = "libwimp.dll"
    

    If you want the Tango icons:

    GTK_ICONS = os.path.join("share", "icons")
    

    There is also localisation data (which I omit, but you might not want to):

    GTK_LOCALE_DATA = os.path.join("share", "locale")
    

    3. Piecing it together

    Firstly, here’s a function that walks the filesystem tree at a given point and produces output suitable for the data_files option.

    def generate_data_files(prefix, tree, file_filter=None):
        """
        Walk the filesystem starting at "prefix" + "tree", producing a list of files
        suitable for the data_files option to setup(). The prefix will be omitted
        from the path given to setup(). For example, if you have
    
            C:\Python26\Lib\site-packages\gtk-2.0\runtime\etc\...
    
        ...and you want your "dist\" dir to contain "etc\..." as a subdirectory,
        invoke the function as
    
            generate_data_files(
                r"C:\Python26\Lib\site-packages\gtk-2.0\runtime",
                r"etc")
    
        If, instead, you want it to contain "runtime\etc\..." use:
    
            generate_data_files(
                r"C:\Python26\Lib\site-packages\gtk-2.0",
                r"runtime\etc")
    
        Empty directories are omitted.
    
        file_filter(root, fl) is an optional function called with a containing
        directory and filename of each file. If it returns False, the file is
        omitted from the results.
        """
        data_files = []
        for root, dirs, files in os.walk(os.path.join(prefix, tree)):        
            to_dir = os.path.relpath(root, prefix)
    
            if file_filter is not None:
                file_iter = (fl for fl in files if file_filter(root, fl))
            else:
                file_iter = files
    
            data_files.append((to_dir, [os.path.join(root, fl) for fl in file_iter]))
    
        non_empties = [(to, fro) for (to, fro) in data_files if fro]
    
        return non_empties
    

    So now you can call setup() like so:

    setup(
        # Other setup args here...
    
        data_files = (
                        # Use the function above...
                        generate_data_files(GTK_RUNTIME_DIR, GTK_THEME_DEFAULT) +
                        generate_data_files(GTK_RUNTIME_DIR, GTK_THEME_WINDOWS) +
                        generate_data_files(GTK_RUNTIME_DIR, GTK_ICONS) +
    
                        # ...or include single files manually
                        [
                            (GTK_GTKRC_DIR, [
                                os.path.join(GTK_RUNTIME_DIR,
                                    GTK_GTKRC_DIR,
                                    GTK_GTKRC)
                            ]),
    
                            (GTK_WIMP_DIR, [
                                os.path.join(
                                    GTK_RUNTIME_DIR,
                                    GTK_WIMP_DIR,
                                    GTK_WIMP_DLL)
                            ])
                        ]
                    )
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
I'm making a simple page using Google Maps API 3. My first. One marker
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.