Image in a module question

Christopher chris_mk at hotmail.com
Thu Mar 28 07:59:45 CET 2002


A while back, I remember somebody mentioning a way to store image data
in a Python module.  This is something I think I could really use (I
want to incorporate an image into an frozen exe that I am writing for
my coworkers).  I would like to keep the installation nice and neat
(--onefile) and I figure the easiest way is to store the image in a
module, import it, then use the string (I am assuming this is what you
would get from the module, I can't remember what the post sais) e.g.,

import MyImageModule
import Image, ImageTk, StringIO

myImage = MyImageModule.MyImage  # Where MyImage is the string
representing the image

im = Image.open(StringIO.StringIO(myImage))
# I can now use im to construct my Tkinter label/button/etc.

I did some searches: PIL, image in module, importing images, etc. and
didn't see the post (it was a lot of pages, i may have just missed
it).  If somebody remembers the post, could you point me to it (just
the date would be a huge help).  Thanks a bunch,

Chris Karim



More information about the Python-list mailing list