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