]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/ImageFromStream.py
fix building/running of tex2rtf
[wxWidgets.git] / wxPython / demo / ImageFromStream.py
CommitLineData
2403536a 1
8fa876ca
RD
2import cStringIO
3
4import wx
2403536a 5
8fa876ca 6from Main import opj
2403536a
RD
7
8#----------------------------------------------------------------------
9
8fa876ca 10class TestPanel(wx.Panel):
2403536a 11 def __init__(self, parent, log):
8fa876ca 12 wx.Panel.__init__(self, parent, -1)
2403536a 13
1e4a197e 14 data = open(opj('bitmaps/image.png'), "rb").read()
8fa876ca
RD
15 stream = cStringIO.StringIO(data)
16
17 bmp = wx.BitmapFromImage( wx.ImageFromStream( stream ))
2403536a 18
8fa876ca
RD
19 wx.StaticText(
20 self, -1, "This image was loaded from a Python file-like object:",
21 (15, 15)
22 )
2403536a 23
8fa876ca 24 wx.StaticBitmap(self, -1, bmp, (15, 45))#, (bmp.GetWidth(), bmp.GetHeight()))
2403536a
RD
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. """
1fded56b
RD
41
42
1fded56b
RD
43if __name__ == '__main__':
44 import sys,os
45 import run
8eca4fef 46 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])