Ticket #14 (new enhancement)
Add hooks for PyGTK themes
| Reported by: | openticket | Owned by: | giovannibajo |
|---|---|---|---|
| Priority: | low | Milestone: | PyInstaller 2.2 |
| Component: | Hooks | Version: | |
| Severity: | normal | Keywords: | |
| Cc: |
Description
I have tried to build a simple PyGTK program, by using PyInstaller? 1.3, accordingly to the suggestions reported in the tickets about PyGTK (hidden imports and Pango files).
Under Windows XP, I have chosen a "theme" for GTK applications, by using the "Theme Selector" application; theme is a sort of visual "look and feel": when I run the script, the chosen theme applies to the window controls; when I run the executable, a standard theme is used instead.
It is probably due to some GTK library settings: if you have fixed the pango problem, I think you should also be able to fix this. All I can tell you is that custom themes (for example, the ones in the user's computer - since it's the user who chooses the themes) are kept under $GTK_HOME/share/themes, and every theme has got a separate directory.
I do not know if this applies to Linux, too.
Attachments
Change History
comment:2 Changed 4 years ago by MeV
I forgot to say that I had to use the following code to load my theme:
import os, gtk
try:
basedir = os.environ['_MEIPASS2']
except KeyError:
basedir = sys.path[0]
#Use embedded gtkrc
gtkrc = os.path.join(basedir, 'gtkrc')
gtk.rc_set_default_files([gtkrc])
gtk.rc_reparse_all_for_settings(gtk.settings_get_default(), True)
To use it, save the code into a file named 'useGTK.py' and add the path to this file to ANALYSIS
comment:3 Changed 15 months ago by htgoebel
- Priority changed from normal to low
- Summary changed from PyGTK themes do not work for frozen executables to Add hooks for PyGTK themes
- Type changed from defect to enhancement
- Milestone set to PyInstaller 2.1
Thanks for the receipt! I've added a link to the wiki.

I successfully added the MS-Windows theme (for better windows integration) to my application by using a code like this:
# First we have to know where gtk is installed, we get this from registry import _winreg import msvcrt try: k = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'Software\\GTK2-Runtime') except EnvironmentError: print 'You must install the Gtk+ 2.2 Runtime Environment to run this program' while not msvcrt.kbhit(): pass sys.exit(1) else: gtkdir = str(_winreg.QueryValueEx(k, 'InstallationDirectory')[0]) gtkversion = str(_winreg.QueryValueEx(k, 'BinVersion')[0]) #Then we want to go to the directory where the gtkrcfile is located gtkrc_dir = os.path.join('share', 'themes', 'MS-Windows', 'gtk-2.0') #Add gtkrc file to exe extra_datas = [ ('gtkrc', os.path.join(gtkdir, gtkrc_dir, 'gtkrc'), 'DATA') ] #Add libwimp.dll to exe (needed for the MS-Windows theme) extra_binaries = [ (os.path.join(engines_dir, 'libwimp.dll'), \ os.path.join(gtkdir, engines_dir, 'libwimp.dll'), 'BINARY') ] #Finally the EXE declaration should looks like this: exe = EXE( pyz, a.scripts, a.binaries + extra_binaries, a.zipfiles, a.datas + extra_datas, name = os.path.join('dist', 'myapp.exe'), icon = os.path.join('icon', 'myicon.ico'), debug = False, strip = False, upx = True, console = False )