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