import images (wxPython)

David Bolen db3l at fitlinxx.com
Tue Feb 12 22:34:25 EST 2002


"Andrew" <anon at anon.com> writes:

> I was looking at some of the demo code and notice that they do an 'import
> images' in some files to get some predefined images.  Now I'm writing my own
> script and would like to make use of those images as well, but I get the
> following error...  ImportError: No module named images.
> I'm still learning python and am not 100% sure how the import statement
> works.  The images file is in the demo folder of the wxPython folder.  I
> tried things like import wxPython.demo.images, but that doesn't work either.
> Can somebody give me a hand?

That's just one of the modules that is part of the demo itself.  You
can't import it with wxPython.demo.images because the demo directory
of wxPython isn't designed as a Python package (it would have to have
an __init__.py file).  That is, the demo isn't really designed to be
included by other applications, at least not in terms of how it is
installed in the filesystem.

You could either include the demo directory in your sys.path (either
via an external definition of PYTHONPATH or by adding it to sys.path
in your code), or just make a copy of the images.py file and stick it
in your application directory and get it locally.

Or if you're just trying to borrow the images, you could just snarf
whichever functions you want from the file and include it in your
application :-)

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list