Py2exe missing buttons icons on navigation toolbar

Hello,

I have a simple program
---------------graf.py--------------

import matplotlib.pyplot as plt
plt.plot([1,2,3,8,0,9,1,10,5])
plt.ylabel('some numbers')
plt.show()

···

--------------------------------------------------
If I look to a matplotlib figures on my screen using the exe made with py2exe I mis all the buttons but one of the navigation bar.
If I work direct with the Python interpreted they are there.
I use the current version of Pythonxy

------------ setup.py --------------
from distutils.core import setup
import py2exe
import matplotlib

name = 'graf.py'
INCLUDES = [ 'sip' , 'matplotlib.numerix.random_array'
                               # , 'PyQt4._qt'
                                        , 'matplotlib.backends'
                                        , 'matplotlib.backends.backend_qt4agg']
#['matplotlib.backends.backend_qt4agg']
EXCLUDES = []
[ '_gtkagg' , '_tkagg' , 'Tkconstants' , 'Tkinter' ,'tcl' ]
#['_tkagg' , '_ps' , '_fltkagg' , 'Tkinter' , 'Tkconstants' , '_cairo' , '_gtk' , 'gtkcairo' ,
            # 'pydoc' , 'sqlite3' , 'bsddb' , 'curses' , 'tcl' , '_wxagg' , '_gtagg' , '_cocoaagg' , '_wx' ]
DLL_EXCLUDES = ['MSVCP90.dll']
ICON_RESOURSES = []
OTHER_RESOURCES = []
DATA_FILES = matplotlib.get_py2exe_datafiles()

setup(name = name,
       version = '1.0',
       options = { "py2exe" : { 'compressed' : 1,
                                         'optimize' : 2,
                                         'bundle_files' : 2,
                                         'includes' : INCLUDES,
                                         'excludes' : EXCLUDES,
                                         'dll_excludes' : DLL_EXCLUDES } } ,
       console = [ { 'script' : name,
                              'icon_resources' : ICON_RESOURSES,
                              'other_resources' : OTHER_RESOURCES, } ] ,
       description = 'Hele mooie',
       author = 'Tom van der Hoeven',
       author_email = 'Tom@...3428...' ,
       maintainer = 'Tom van der Hoeven',
       maintainer_email = 'Tom@...3428...',
       license = '',
       url = 'http://projecthomepage.com',
       data_files = DATA_FILES,
       )
-------------------------
can you help me

Tom

Hello Tom,

I encountered the same problem recently. The toolbar icons are a mix of png and svg images. The png images are displayed properly while the svg icons are not shown. This is a problem with PyQt. I found a proposal on the web, where you should add the line

     import PyQt4.QtXml

somewhere to your code. This is because xml support is needed to read svg files. However, this did not work for me. Instead I now use a rather ugly workaround: I rename the original *.png icon files to *.svg for those icons that are expected to be svg files. Qt will then find an svg file but it's clever enough to load it as png.
Save those modified files somewhere as resources. Add them to the data_files list in your setup script and they will overwrite the original files at every build so you don't have to care any more.

You can find out which files have to be renamed by looking into PACKAGEPATH/matplotlib/backends/backend_qt4.py line 399 and below. Another approach would be to directly rename the files in NavigationToolbar2QT._init_toolbar() to *.png since matplotlib provides png and svg files for every icon.

Greetings,
     Sebastian

···

Am 06.02.2011 11:20, schrieb Tom van der Hoeven:

Hello,

I have a simple program
---------------graf.py--------------

import matplotlib.pyplot as plt
plt.plot([1,2,3,8,0,9,1,10,5])
plt.ylabel('some numbers')
plt.show()
--------------------------------------------------
If I look to a matplotlib figures on my screen using the exe made with
py2exe I mis all the buttons but one of the navigation bar.
If I work direct with the Python interpreted they are there.
I use the current version of Pythonxy

------------ setup.py --------------
from distutils.core import setup
import py2exe
import matplotlib

name = 'graf.py'
INCLUDES = [ 'sip' , 'matplotlib.numerix.random_array'
                                # , 'PyQt4._qt'
                                         , 'matplotlib.backends'
                                         ,
'matplotlib.backends.backend_qt4agg']
#['matplotlib.backends.backend_qt4agg']
EXCLUDES = []
[ '_gtkagg' , '_tkagg' , 'Tkconstants' , 'Tkinter' ,'tcl' ]
#['_tkagg' , '_ps' , '_fltkagg' , 'Tkinter' , 'Tkconstants' , '_cairo' ,
'_gtk' , 'gtkcairo' ,
             # 'pydoc' , 'sqlite3' , 'bsddb' , 'curses' , 'tcl' ,
'_wxagg' , '_gtagg' , '_cocoaagg' , '_wx' ]
DLL_EXCLUDES = ['MSVCP90.dll']
ICON_RESOURSES = []
OTHER_RESOURCES = []
DATA_FILES = matplotlib.get_py2exe_datafiles()

setup(name = name,
        version = '1.0',
        options = { "py2exe" : { 'compressed' : 1,
                                          'optimize' : 2,
                                          'bundle_files' : 2,
                                          'includes' : INCLUDES,
                                          'excludes' : EXCLUDES,
                                          'dll_excludes' : DLL_EXCLUDES }
} ,
        console = [ { 'script' : name,
                               'icon_resources' : ICON_RESOURSES,
                               'other_resources' : OTHER_RESOURCES, } ] ,
        description = 'Hele mooie',
        author = 'Tom van der Hoeven',
        author_email = 'Tom@...3428...' ,
        maintainer = 'Tom van der Hoeven',
        maintainer_email = 'Tom@...3428...',
        license = '',
        url = 'http://projecthomepage.com',
        data_files = DATA_FILES,
        )
-------------------------
can you help me

Tom

------------------------------------------------------------------------------
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world?
http://p.sf.net/sfu/oracle-sfdevnlfb
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Dear Sebastian,

Your solution is simple, well described and it works with minimal effort
Thank you so much!
I hope the Matplotlib devellopers will take some action.

Tom

Op 6-2-2011 13:16, Sebastian Voigt schreef:

···

Hello Tom,

I encountered the same problem recently. The toolbar icons are a mix of
png and svg images. The png images are displayed properly while the svg
icons are not shown. This is a problem with PyQt. I found a proposal on
the web, where you should add the line

      import PyQt4.QtXml

somewhere to your code. This is because xml support is needed to read
svg files. However, this did not work for me. Instead I now use a rather
ugly workaround: I rename the original *.png icon files to *.svg for
those icons that are expected to be svg files. Qt will then find an svg
file but it's clever enough to load it as png.
Save those modified files somewhere as resources. Add them to the
data_files list in your setup script and they will overwrite the
original files at every build so you don't have to care any more.

You can find out which files have to be renamed by looking into
PACKAGEPATH/matplotlib/backends/backend_qt4.py line 399 and below.
Another approach would be to directly rename the files in
NavigationToolbar2QT._init_toolbar() to *.png since matplotlib provides
png and svg files for every icon.

Greetings,
      Sebastian

Am 06.02.2011 11:20, schrieb Tom van der Hoeven:

Hello,

I have a simple program
---------------graf.py--------------

import matplotlib.pyplot as plt
plt.plot([1,2,3,8,0,9,1,10,5])
plt.ylabel('some numbers')
plt.show()
--------------------------------------------------
If I look to a matplotlib figures on my screen using the exe made with
py2exe I mis all the buttons but one of the navigation bar.
If I work direct with the Python interpreted they are there.
I use the current version of Pythonxy

------------ setup.py --------------
from distutils.core import setup
import py2exe
import matplotlib

name = 'graf.py'
INCLUDES = [ 'sip' , 'matplotlib.numerix.random_array'
                                 # , 'PyQt4._qt'
                                          , 'matplotlib.backends'
                                          ,
'matplotlib.backends.backend_qt4agg']
#['matplotlib.backends.backend_qt4agg']
EXCLUDES = []
[ '_gtkagg' , '_tkagg' , 'Tkconstants' , 'Tkinter' ,'tcl' ]
#['_tkagg' , '_ps' , '_fltkagg' , 'Tkinter' , 'Tkconstants' , '_cairo' ,
'_gtk' , 'gtkcairo' ,
              # 'pydoc' , 'sqlite3' , 'bsddb' , 'curses' , 'tcl' ,
'_wxagg' , '_gtagg' , '_cocoaagg' , '_wx' ]
DLL_EXCLUDES = ['MSVCP90.dll']
ICON_RESOURSES = []
OTHER_RESOURCES = []
DATA_FILES = matplotlib.get_py2exe_datafiles()

setup(name = name,
         version = '1.0',
         options = { "py2exe" : { 'compressed' : 1,
                                           'optimize' : 2,
                                           'bundle_files' : 2,
                                           'includes' : INCLUDES,
                                           'excludes' : EXCLUDES,
                                           'dll_excludes' : DLL_EXCLUDES }
} ,
         console = [ { 'script' : name,
                                'icon_resources' : ICON_RESOURSES,
                                'other_resources' : OTHER_RESOURCES, } ] ,
         description = 'Hele mooie',
         author = 'Tom van der Hoeven',
         author_email = 'Tom@...3428...' ,
         maintainer = 'Tom van der Hoeven',
         maintainer_email = 'Tom@...3428...',
         license = '',
         url = 'http://projecthomepage.com',
         data_files = DATA_FILES,
         )
-------------------------
can you help me

Tom

------------------------------------------------------------------------------
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world?
http://p.sf.net/sfu/oracle-sfdevnlfb
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

------------------------------------------------------------------------------
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world?
http://p.sf.net/sfu/oracle-sfdevnlfb
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users