Hi Giorgio,

Had a quick look at pylab based scripts and got an error on backend_tkagg when py2exe it. It looks like one needs to force the backend to be included, I used tkagg but you would have to replace that with wxagg for your script.

Attached is a setup.py and from the examples the file simple_plot.py.

Werner
# -*- coding: iso-8859-1 -*-#
from distutils.core import setup
import os
from os.path import join
import shutil

import glob
import py2exe
from py2exe.build_exe import py2exe
import sys

import matplotlib
mpdir, mpfiles = matplotlib.get_py2exe_datafiles()

# cleanup dist and build directory first (for new py2exe version)
if os.path.exists("dist/prog"):
    shutil.rmtree("dist/prog")

if os.path.exists("dist/lib"):
    shutil.rmtree("dist/lib")

if os.path.exists("build"):
    shutil.rmtree("build")
    


#
# A program using wxPython

# The manifest will be inserted as resource into the .exe.  This
# gives the controls the Windows XP appearance (if run on XP ;-)
#
manifest_template = '''
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
    version="5.0.0.0"
    processorArchitecture="x86"
    name="%(prog)s"
    type="win32"
/>
<description>%(prog)s</description>
<dependency>
    <dependentAssembly>
        <assemblyIdentity
            type="win32"
            name="Microsoft.Windows.Common-Controls"
            version="6.0.0.0"
            processorArchitecture="X86"
            publicKeyToken="6595b64144ccf1df"
            language="*"
        />
    </dependentAssembly>
</dependency>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="AsInvoker"
          uiAccess="false"/>
        </requestedPrivileges>
       </security>
  </trustInfo>
</assembly>
'''

RT_MANIFEST = 32
#

# options for py2exe
options = {"py2exe": {"compressed": 1,
                      "optimize": 2,
                      "packages": ["encodings",
                                   "pytz.zoneinfo.UTC", "matplotlib.numerix", 
"matplotlib.backends.backend_tkagg"
                                   ],
                      "excludes": ["MySQLdb", ],
                      "dll_excludes": ["wxmsw26uh_vc.dll"]
                      }
          }
zipfile = r"lib\library.zip"

class MetaBase:
    def __init__(self, **kw):
        self.__dict__.update(kw)
        self.version = '1.0'
        self.author = "yourname"
        self.author_email = "[EMAIL PROTECTED]"
        self.company_name = ""
        self.copyright = "2003 - 2007 by whoever"
        self.url = "http://www.whatever.com/";
        self.download_url = "http://www.whatever.com/en/";
        self.trademark = ""
        self.comments = "a comment on the prog"
        self.name = "the prog name"
        self.description = "a desc on the prog"

wx_emb = MetaBase(
            script = "simple_plot.py",
            other_resources = [(RT_MANIFEST, 1, manifest_template % 
dict(prog="your prog name"))],
##            icon_resources = [(1, r"images/some.ico")],
            dest_base = r"prog\simple_plot")

setup(
      classifiers = ["Copyright:: your name",
                     "Development Status :: 5 Stable",
                     "Intended Audience :: End User",
                     "License :: Shareware",
                     "Operating System :: Microsoft :: Windows 2000",
                     "Operating System :: Microsoft :: Windows XP",
                     "Operating System :: Microsoft :: Windows 9x",
                     "Programming Language :: Python, wxPython",
                     "Topic :: Home Use"
                     "Natural Language :: German",
                     "Natural Language :: French",
                     "Natural Language :: English"],
      windows = [wx_emb],
      options = options,
      zipfile = zipfile,
      data_files = [("lib\\matplotlibdata", mpfiles),
##                    matplotlib.get_py2exe_datafiles(), # if you don't use the 
lib option
                    ]
    )
#!/usr/bin/env python
"""
Example: simple line plot.
Show how to make and save a simple line plot with labels, title and grid
"""
from pylab import *

t = arange(0.0, 1.0+0.01, 0.01)
s = cos(2*2*pi*t)
plot(t, s)

xlabel('time (s)')
ylabel('voltage (mV)')
title('About as simple as it gets, folks')
grid(True)

#savefig('simple_plot.png')
savefig('simple_plot')

show()
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to