Resolving: Matplotlib icons disappears in one file setup.

41 views
Skip to first unread message

Laurent

unread,
Dec 13, 2009, 10:59:51 AM12/13/09
to PyInstaller
Hello,

I had an issue before with either py2exe or pyinstaller.
Packing matplotlib toolbar in a single file .exe make disappear most
of the icons on this toolbar.

The issue is only seen with .svg icon file.
.png are ok.
(I use also pyqt)

Here is dirty patch, add this to your own code:

from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg
as NavigationToolbar

class VMToolbar(NavigationToolbar):

def __init__(self, plotCanvas, parent):
NavigationToolbar.__init__(self, plotCanvas, parent)

def _icon(self, name):
#dirty hack to use exclusively .png and thus avoid .svg usage
#because .exe generation is problematic with .svg
name = name.replace('.svg','.png')
return QIcon(os.path.join(self.basedir, name))

Well this is far from perfect but at least it avoid the issue if your
are like me in a urge to release a .exe :)

Cheers,
Laurent

Giovanni Bajo

unread,
Jan 8, 2010, 1:41:49 PM1/8/10
to pyins...@googlegroups.com

The problem with svg usually is that it impliclty depends on QtXml. So,
it might be that PyInstaller doesn't bring QtXml in because it doesn't
know you are going to use the svg plugin.

Try to add an explicit "import PyQt4.QtXml" line somewhere, and svg will
start working.

--
Giovanni Bajo
Develer S.r.l.
http://www.develer.com


Álvaro Parra

unread,
Mar 2, 2011, 3:24:10 PM3/2/11
to pyins...@googlegroups.com
It doesn't work to me. Could you solve the problem with only the import?
Any other idea how to solve this problem?
Reply all
Reply to author
Forward
0 new messages