]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/ImageFromStream.py
bash version of wxPython's b script for win32
[wxWidgets.git] / wxPython / demo / ImageFromStream.py
1
2 import cStringIO
3
4 import wx
5
6 from Main import opj
7
8 #----------------------------------------------------------------------
9
10 class 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
30 def runTest(frame, nb, log):
31 win = TestPanel(nb, log)
32 return win
33
34 #----------------------------------------------------------------------
35
36
37 overview = """\
38 At long last there is finally a way to load any supported image type
39 directly from any Python file-like object, such as a memory buffer
40 using StringIO. """
41
42
43 if __name__ == '__main__':
44 import sys,os
45 import run
46 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])