PyInstaller with wx.lib.agw.aui

60 views
Skip to first unread message

Scott

unread,
Feb 2, 2012, 5:45:45 PM2/2/12
to PyInstaller
I'm trying to use PyInstaller to freeze my python application. It
uses wxpython, and specifically uses the aui package. In wxpython,
there are two aui packages:

import wx.lib.agw.aui as aui
#import wx.aui as aui

I need to use the first one listed above. However, when I freeze my
program, the GUI looses the XP theme and it looks like that classic
windows 98 look. When run normally in python, it works fine.
However, if I use the second aui package above, then it looks normal -
both when frozen and run normally in python. As mentioned, in the
end, I need to use that first aui package...but I'd like the theme to
remain the same.

I am using:
Windows XP
Python 2.7.1
wxPython 2.8.12.1

For testing, all you need to do is import this package (even if it
isn't used). The example below can be used for testing. Run it as-
is, and the frozen exe displays with the old windows look. But
comment the first aui line and un-comment the second, things work
fine...:

-----[ Test.py ]---------------------------------------
import wx
import wx.lib.agw.aui as aui
#import wx.aui as aui
class MyFrame(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, title=title, size=(200,100))
self.control = wx.Button(self, label='Button')
self.Show(True)
app = wx.App(False)
frame = MyFrame(None, 'Small editor')
app.MainLoop()
---------------------------------------------------------------

-----[ Test.spec ]---------------------------------------
# -*- mode: python -*-
a = Analysis([os.path.join(HOMEPATH,'support\\_mountzlib.py'),
os.path.join(HOMEPATH,'support\\useUnicode.py'),
'Test.py'])
pyz = PYZ(a.pure)
exe = EXE( pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name=os.path.join('pyInstDist', 'sampleApp.exe'),
debug=False,
strip=False,
upx=True,
console=False)
---------------------------------------------------------------

Hartmut Goebel

unread,
Feb 7, 2012, 8:58:00 AM2/7/12
to pyins...@googlegroups.com
Am 02.02.2012 23:45, schrieb Scott:
> import wx.lib.agw.aui as aui
> #import wx.aui as aui
>
> I need to use the first one listed above. However, when I freeze my
> program, the GUI looses the XP theme and it looks like that classic
> windows 98 look. When run normally in python, it works fine.
> However, if I use the second aui package above, then it looks normal -
> both when frozen and run normally in python. As mentioned, in the

You need to find out, what is missing, See
<http://www.pyinstaller.org/wiki/HowtoReportBugs#Beforesubmittingareport:Makesureeverythingispackaged>
for some tools to get this known.

--
Schönen Gruß - Regards
Hartmut Goebel
Dipl.-Informatiker (univ.), CISSP, CSSLP

Goebel Consult
Spezialist für IT-Sicherheit in komplexen Umgebungen
http://www.goebel-consult.de

Monatliche Kolumne: http://www.cissp-gefluester.de/
Goebel Consult ist Mitglied bei http://www.7-it.de


Andrea Gavana

unread,
Feb 7, 2012, 9:07:46 AM2/7/12
to pyins...@googlegroups.com
Hi,

On 7 February 2012 14:58, Hartmut Goebel wrote:
> Am 02.02.2012 23:45, schrieb Scott:
>>
>> import wx.lib.agw.aui as aui
>> #import wx.aui as aui
>>
>> I need to use the first one listed above.  However, when I freeze my
>> program, the GUI looses the XP theme and it looks like that classic
>> windows 98 look.  When run normally in python, it works fine.
>> However, if I use the second aui package above, then it looks normal -
>> both when frozen and run normally in python.  As mentioned, in the
>
>
> You need to find out, what is missing, See
> <http://www.pyinstaller.org/wiki/HowtoReportBugs#Beforesubmittingareport:Makesureeverythingispackaged>
> for some tools to get this known.

You have to remove any reference/link to the UxTheme.dll library in
your spec file. This is what I do:

exe = EXE( pyz,
a.scripts,

a.binaries - [('UxTheme.dll',
r'C:\Windows\System32\uxtheme.dll', 'BINARY'), ('uxtheme.dll',
r'C:\Windows\System32\uxtheme.dll', 'BINARY')],
a.zipfiles,
a.datas,
name=WHATEVER,
debug=False,
strip=False,
upx=True,
console=False , icon='whatever.ico')


Unfortunately this is almost unavoidable as wx.lib.agw.aui, as the
whole AGW, contains custom-drawn widgets which normally require the
use of UxTheme to look right on Windows (>= XP).

Hope this helps.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

>>> import PyQt4.QtGui
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
ImportError: No module named PyQt4.QtGui
>>>
>>> import pygtk
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
ImportError: No module named pygtk
>>>
>>> import wx
>>>
>>>

Scott

unread,
Feb 7, 2012, 12:42:13 PM2/7/12
to PyInstaller
Thanks for the insight Andrea. Removing UxTheme as you suggested
seems to solve the problem. Why does it work? Aren't we excluding
UxTheme, even though you said it is necessary? And why does it look
OK when using "import wx.aui as aui", does it not require UxTheme in
the same way? Just curious...

Thanks,
Scott

On Feb 7, 6:07 am, Andrea Gavana <andrea.gav...@gmail.com> wrote:
> Hi,
>
> On 7 February 2012 14:58, Hartmut Goebel wrote:
>
> > Am 02.02.2012 23:45, schrieb Scott:
>
> >> import wx.lib.agw.aui as aui
> >> #import wx.aui as aui
>
> >> I need to use the first one listed above.  However, when I freeze my
> >> program, the GUI looses the XP theme and it looks like that classic
> >> windows 98 look.  When run normally in python, it works fine.
> >> However, if I use the second aui package above, then it looks normal -
> >> both when frozen and run normally in python.  As mentioned, in the
>
> > You need to find out, what is missing, See
> > <http://www.pyinstaller.org/wiki/HowtoReportBugs#Beforesubmittingarepo...>

Andrea Gavana

unread,
Feb 9, 2012, 3:51:02 AM2/9/12
to pyins...@googlegroups.com
Hi Scott,

On 7 February 2012 18:42, Scott wrote:
> Thanks for the insight Andrea.  Removing UxTheme as you suggested
> seems to solve the problem.  Why does it work?  Aren't we excluding
> UxTheme, even though you said it is necessary?

We are excluding it because all Windows installation (XP and greater)
have this UxTheme.dll thing installed by default, normally in
C:\Windows\system32\uxtheme.dll. It is a library used for
skinning/window appearance on Windows. As it is always installed on
any Windows machine, no exception, there is no need for the executable
builders to pick it up. Unfortunately, none of the executable builders
I know of (PyInstaller, py2exe, cx_Freeze, bbFreeze, vendorID) are
smart enough to figure this out, so we need to exclude it manually.

If you don't exclude it, the local copy of UxTheme.dll installed by
your application will conflict with the original system one, and all
hell will break loose.

> And why does it look
> OK when using "import wx.aui as aui", does it not require UxTheme in
> the same way?  Just curious...

wx.aui is written in C++ and wrapped in Python and it doesn't have all
the whistles and bells of agw.aui. One of the reasons why agw.aui
needs UxTheme.dll on Windows is the use of the ModernDockArt class (in
dockart.py), which will make the docking/floating experience 100%
native on Windows (and not with the fake captions/borders styles shown
by wx.aui, which does not have that class).

Hartmut Goebel

unread,
Feb 9, 2012, 4:06:21 AM2/9/12
to pyins...@googlegroups.com
Am 09.02.2012 09:51, schrieb Andrea Gavana:
> We are excluding it because all Windows installation (XP and greater)
> have this UxTheme.dll thing installed by default, normally in
> C:\Windows\system32\uxtheme.dll. It is a library used for
> skinning/window appearance on Windows. As it is always installed on
> any Windows machine, no exception, there is no need for the executable
> builders to pick it up. Unfortunately, none of the executable builders
> I know of (PyInstaller, py2exe, cx_Freeze, bbFreeze, vendorID) are
> smart enough to figure this out, so we need to exclude it manually.

Please open a bug-ticket for this one. PyInstaller ha a list of dlls to
exclude, we could simply add it there. Please but a link to this thread
there for reference. Thanks.

If I understand it right, this would solve the problem and the
workaround you described in
<http://groups.google.com/group/pyinstaller/msg/13edf6a37fbbe70f> would
not be necessary.

Martin Zibricky

unread,
Feb 9, 2012, 6:54:05 AM2/9/12
to pyins...@googlegroups.com
Hartmut Goebel píše v Čt 09. 02. 2012 v 10:06 +0100:

> Please open a bug-ticket for this one. PyInstaller ha a list of dlls
> to
> exclude, we could simply add it there.

What pyinstaller version are we speaking about? 1.5.1?

The development version from git excludes every dll from windows
directory. This has to be fixed in future release 1.5.2.

Reply all
Reply to author
Forward
0 new messages