[wxPython-users] determine App instance

Christopher Barker Chris.Barker at noaa.gov
Sat Dec 15 22:19:10 PST 2007


Raffaello Barella wrote:
> Would you please let me know how to store an image inside an 
> application, either in one/many frames or in the object TheApp? I 
> thought it was only possible to load  the image from an existing file 
> any time it was needed.

A couple options:

1) take a look at the img2py utility that comes with wxPython. It takes 
an image and stores it in a python module that can then be loaded, and 
the image extracted as either a wx.Image or wx.Bitmap.

2) IN your wx.App OnInit() (or anywhere, really) you do something like:


self.AParticularBitmap - wx.Bitmap(TheFileName)

Now you have a reference to that bitmap that you can use anywhere you 
need one.

My tendency would be to put all of these sorts of things in a 
"Resource'" module or package that you import and use anywhere you need it.

-Chris



-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov




More information about the wxpython-users mailing list