]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/ImageFromStream.py
1 # 11/19/2003 - Jeff Grimmett (grimmtooth@softhome.net)
3 # o Updated for wx namespace
12 #----------------------------------------------------------------------
14 class TestPanel(wx
.Panel
):
15 def __init__(self
, parent
, log
):
16 wx
.Panel
.__init
__(self
, parent
, -1)
18 data
= open(opj('bitmaps/image.png'), "rb").read()
19 stream
= cStringIO
.StringIO(data
)
21 bmp
= wx
.BitmapFromImage( wx
.ImageFromStream( stream
))
24 self
, -1, "This image was loaded from a Python file-like object:",
28 wx
.StaticBitmap(self
, -1, bmp
, (15, 45))#, (bmp.GetWidth(), bmp.GetHeight()))
32 #----------------------------------------------------------------------
34 def runTest(frame
, nb
, log
):
35 win
= TestPanel(nb
, log
)
38 #----------------------------------------------------------------------
42 At long last there is finally a way to load any supported image type
43 directly from any Python file-like object, such as a memory buffer
47 if __name__
== '__main__':
50 run
.main(['', os
.path
.basename(sys
.argv
[0])])