blob: 7a3629c071130247c09d084f798e3408ffeec96f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# bitmap.py
import wx
import waxobject
import image
import cStringIO
# XXX not sure what to do with this
class Bitmap(wx.StaticBitmap, waxobject.WaxObject):
def __init__(self, parent, bitmap):
if isinstance(bitmap, str) or isinstance(bitmap, unicode):
bitmap = BitmapFromFile(bitmap)
wx.StaticBitmap.__init__(self, parent, wx.NewId(), bitmap)
# XXX supposedly you can load this from file too?
#
# use these functions for convenience...
# unfortunately, they return wxBitmaps, not Bitmaps
def BitmapFromData(data):
stream = cStringIO.StringIO(data)
z = wx.ImageFromStream(stream)
return wx.BitmapFromImage(z)
def BitmapFromFile(filename):
data = open(filename, 'rb').read()
return BitmapFromData(data)
|