]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/wxImageFromStream.py
reSWIGged
[wxWidgets.git] / wxPython / demo / wxImageFromStream.py
CommitLineData
8fa876ca
RD
1# 11/19/2003 - Jeff Grimmett (grimmtooth@softhome.net)
2#
3# o Updated for wx namespace
4#
2403536a 5
8fa876ca
RD
6import cStringIO
7
8import wx
2403536a 9
8fa876ca 10from Main import opj
2403536a
RD
11
12#----------------------------------------------------------------------
13
8fa876ca 14class TestPanel(wx.Panel):
2403536a 15 def __init__(self, parent, log):
8fa876ca 16 wx.Panel.__init__(self, parent, -1)
2403536a 17
1e4a197e 18 data = open(opj('bitmaps/image.png'), "rb").read()
8fa876ca
RD
19 stream = cStringIO.StringIO(data)
20
21 bmp = wx.BitmapFromImage( wx.ImageFromStream( stream ))
2403536a 22
8fa876ca
RD
23 wx.StaticText(
24 self, -1, "This image was loaded from a Python file-like object:",
25 (15, 15)
26 )
2403536a 27
8fa876ca 28 wx.StaticBitmap(self, -1, bmp, (15, 45))#, (bmp.GetWidth(), bmp.GetHeight()))
2403536a
RD
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. """
1fded56b
RD
45
46
1fded56b
RD
47if __name__ == '__main__':
48 import sys,os
49 import run
50 run.main(['', os.path.basename(sys.argv[0])])