Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/pynxc/waxy/bitmap.py
blob: 49f0f8af7df696ea1b2e6ad27a1f86c78b959fa9 (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 waxyobject
import image
import cStringIO

# XXX not sure what to do with this
class Bitmap(wx.StaticBitmap, waxyobject.WaxyObject):

    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)