]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/ImageFromStream.py
doc tweaks, typo fixed, etc.
[wxWidgets.git] / wxPython / demo / ImageFromStream.py
1 # 11/19/2003 - Jeff Grimmett (grimmtooth@softhome.net)
2 #
3 # o Updated for wx namespace
4 #
5
6 import cStringIO
7
8 import wx
9
10 from Main import opj
11
12 #----------------------------------------------------------------------
13
14 class 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
34 def runTest(frame, nb, log):
35 win = TestPanel(nb, log)
36 return win
37
38 #----------------------------------------------------------------------
39
40
41 overview = """\
42 At long last there is finally a way to load any supported image type
43 directly from any Python file-like object, such as a memory buffer
44 using StringIO. """
45
46
47 if __name__ == '__main__':
48 import sys,os
49 import run
50 run.main(['', os.path.basename(sys.argv[0])])