Re: [Pyinstaller] #14: PyGTK themes do not work for frozen executables

113 views
Skip to first unread message

PyInstaller Ticket

unread,
Nov 2, 2009, 1:16:52 PM11/2/09
to PyIns...@googlegroups.com
#14: PyGTK themes do not work for frozen executables
-------------------------+--------------------------------------------------
Reporter: openticket | Owner: giovannibajo
Type: defect | Status: new
Priority: normal | Milestone:
Component: PyInstaller | Version:
Severity: normal | Keywords:
-------------------------+--------------------------------------------------

Comment(by MeV):

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 )

}}}

--
Ticket URL: <http://www.pyinstaller.org/ticket/14#comment:1>
Pyinstaller <http://www.pyinstaller.org>
PyInstaller Project

PyInstaller Ticket

unread,
Nov 2, 2009, 1:24:12 PM11/2/09
to PyIns...@googlegroups.com
#14: PyGTK themes do not work for frozen executables
-------------------------+--------------------------------------------------
Reporter: openticket | Owner: giovannibajo
Type: defect | Status: new
Priority: normal | Milestone:
Component: PyInstaller | Version:
Severity: normal | Keywords:
-------------------------+--------------------------------------------------

Comment(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

--
Ticket URL: <http://www.pyinstaller.org/ticket/14#comment:2>

Reply all
Reply to author
Forward
0 new messages