[wxPython] Pickling an image file...

"Olivier Dagenais" <olidag42@hotmail.com>

Before I start implementing a StringInputStream (and
StringOutputStream) of some sort that subclasses wxInputStream (and
wxOuputStream), I'd like to ask if anybody has done this before (and
if there's code I can use) or if there's a better way of hiding my
logo in my code, short of using a database.

How are you planning on handling the actual distribution of your
application in general? If you're using Gordon McMillan's 'installer'
package, then you can add any random file you want into the CArchive
executable image that it creates, and then access them from within
your application whenever you want. Even if you aren't using the
package for distribution, his CArchive or Archive/ZlibArchive classes
may prove useful as a way to package arbitrary files and then extract
them from within your script. The only rub here is that the
current wxPython SplashScreen class requires a file rather than an
in-memory image, so you'd have to write the file locally before using
SplashScreen - but since you'd be writing it each time you ran you'd
still be immune from editing.

To do this, just include the icon in a "misc" clause for the
standalone executable (the MYSTANDALONE clause if you used any of the
automated configuration building). The installer package will just append
any such entries to the CArchive (your "package".exe file).

Then in your code, do something like this (here the name of my
application is 'wxsim' and my splashscreen is 'wxsim.gif'):

    archive = carchive.CArchive('wxsim.exe') # Opening myself
    imgfile = open('wxsim.gif','wb')
    (ispkg,contents) = archive.extract('wxsim.gif')
    imgfile.write(contents)
    imgfile.close()

and after this you can reference wxsim.gif for your splashscreen. You
could also be nice and clean up the file before exiting, or even
modify SplashScreen to accept a direct image.

-- David

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