1
# Copyright (C) 2007-2008 www.stani.be
3
# This program is free software: you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation, either version 3 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program. If not, see http://www.gnu.org/licenses/
17
from cStringIO import StringIO
18
from urllib2 import urlopen
22
from formField import is_www_file
24
def bitmap(icon,size=(48,48),client=wx.ART_OTHER):
26
return wx.ArtProvider_GetBitmap(getattr(wx,icon),client,size)
28
return wx.BitmapFromImage(image(icon))
30
def image(icon,size=(48,48)):
32
return wx.ImageFromBitmap(bitmap(icon,size))
34
return wx.ImageFromStream(StringIO(zlib.decompress(icon)))
38
def bitmap_open(x,height=64):
40
return CACHE[(x,height)]
44
im = wx.ImageFromStream(StringIO(urlopen(x).read()))
47
im = CACHE[(x,height)] = im.Rescale(
48
float(height)*im.GetWidth()/im.GetHeight(),height