]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxImageFromStream.py
2 from wxPython
.wx
import *
5 from cStringIO
import StringIO
7 #----------------------------------------------------------------------
9 class TestPanel(wxPanel
):
10 def __init__(self
, parent
, log
):
11 wxPanel
.__init
__(self
, parent
, -1)
13 data
= open(opj('bitmaps/image.png'), "rb").read()
14 stream
= StringIO(data
)
16 bmp
= wxBitmapFromImage( wxImageFromStream( stream
))
18 wxStaticText(self
, -1,
19 "This image was loaded from a Python file-like object:",
21 wxStaticBitmap(self
, -1, bmp
, (15, 45))#, (bmp.GetWidth(), bmp.GetHeight()))
25 #----------------------------------------------------------------------
27 def runTest(frame
, nb
, log
):
28 win
= TestPanel(nb
, log
)
31 #----------------------------------------------------------------------
35 At long last there is finally a way to load any supported image type
36 directly from any Python file-like object, such as a memory buffer
42 if __name__
== '__main__':
45 run
.main(['', os
.path
.basename(sys
.argv
[0])])