]>
Commit | Line | Data |
---|---|---|
2403536a | 1 | |
8fa876ca RD |
2 | import cStringIO |
3 | ||
4 | import wx | |
2403536a | 5 | |
8fa876ca | 6 | from Main import opj |
2403536a RD |
7 | |
8 | #---------------------------------------------------------------------- | |
9 | ||
8fa876ca | 10 | class 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 | ||
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. """ | |
1fded56b RD |
41 | |
42 | ||
1fded56b RD |
43 | if __name__ == '__main__': |
44 | import sys,os | |
45 | import run | |
46 | run.main(['', os.path.basename(sys.argv[0])]) |