]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/demo/wxImageFromStream.py
reSWIGged
[wxWidgets.git] / wxPython / demo / wxImageFromStream.py
... / ...
CommitLineData
1
2from wxPython.wx import *
3from Main import opj
4
5from cStringIO import StringIO
6
7#----------------------------------------------------------------------
8
9class TestPanel(wxPanel):
10 def __init__(self, parent, log):
11 wxPanel.__init__(self, parent, -1)
12
13 data = open(opj('bitmaps/image.png'), "rb").read()
14 stream = StringIO(data)
15
16 bmp = wxBitmapFromImage( wxImageFromStream( stream ))
17
18 wxStaticText(self, -1,
19 "This image was loaded from a Python file-like object:",
20 (15, 15))
21 wxStaticBitmap(self, -1, bmp, (15, 45))#, (bmp.GetWidth(), bmp.GetHeight()))
22
23
24
25#----------------------------------------------------------------------
26
27def runTest(frame, nb, log):
28 win = TestPanel(nb, log)
29 return win
30
31#----------------------------------------------------------------------
32
33
34overview = """\
35At long last there is finally a way to load any supported image type
36directly from any Python file-like object, such as a memory buffer
37using StringIO. """
38
39
40
41
42if __name__ == '__main__':
43 import sys,os
44 import run
45 run.main(['', os.path.basename(sys.argv[0])])
46