]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/ImageFromStream.py
8 #----------------------------------------------------------------------
10 class TestPanel(wx
.Panel
):
11 def __init__(self
, parent
, log
):
12 wx
.Panel
.__init
__(self
, parent
, -1)
14 data
= open(opj('bitmaps/image.png'), "rb").read()
15 stream
= cStringIO
.StringIO(data
)
17 bmp
= wx
.BitmapFromImage( wx
.ImageFromStream( stream
))
20 self
, -1, "This image was loaded from a Python file-like object:",
24 wx
.StaticBitmap(self
, -1, bmp
, (15, 45))#, (bmp.GetWidth(), bmp.GetHeight()))
28 #----------------------------------------------------------------------
30 def runTest(frame
, nb
, log
):
31 win
= TestPanel(nb
, log
)
34 #----------------------------------------------------------------------
38 At long last there is finally a way to load any supported image type
39 directly from any Python file-like object, such as a memory buffer
43 if __name__
== '__main__':
46 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])