1 # -*- coding: UTF-8 -*-
2 # vim: expandtab sw=4 ts=4 sts=4:
5 Image displaying classes to be embdeded inside wxHTML
7 __author__
= 'Michal Čihař'
8 __email__
= 'michal@cihar.com'
10 Copyright © 2003 - 2010 Michal Čihař
12 This program is free software; you can redistribute it and/or modify it
13 under the terms of the GNU General Public License version 2 as published by
14 the Free Software Foundation.
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 import wx
.lib
.throbber
55 class MemoryInputStream(wx
.InputStream
):
56 def __init__(self
, data
):
58 wx
.InputStream
.__init
__(self
,cStringIO
.StringIO(data
))
60 class EncodedBitmap(wx
.StaticBitmap
):
61 def __init__(self
, parent
, tooltip
= 'Image', image
= defaultbmp
, size
= None, scale
= 1):
62 image
= wx
.ImageFromStream(MemoryInputStream(base64
.b64decode(image
)))
64 bitmap
= wx
.BitmapFromImage(image
.Scale(bitmap
.GetWidth() * scale
, bitmap
.GetHeight() * scale
))
66 bitmap
= wx
.BitmapFromImage(image
)
67 wx
.StaticBitmap
.__init
__(self
, parent
, -1, bitmap
, (0,0))
68 self
.SetToolTipString(tooltip
)
70 class Bitmap(wx
.StaticBitmap
):
71 def __init__(self
, parent
, tooltip
= 'Image', image
= defaultbmp
, size
= None, scale
= 1):
72 bitmap
= wx
.BitmapFromXPMData(image
)
74 img
= wx
.ImageFromBitmap(bitmap
)
75 bitmap
= wx
.BitmapFromImage(img
.Scale(bitmap
.GetWidth() * scale
, bitmap
.GetHeight() * scale
))
76 wx
.StaticBitmap
.__init
__(self
, parent
, -1, bitmap
, (0,0))
77 self
.SetToolTipString(tooltip
)
79 class Throbber(wx
.lib
.throbber
.Throbber
):
80 def __init__(self
, parent
, tooltip
= 'Animation', images
= [defaultbmp
], size
= None, scale
= 1, delay
= 0.1):
83 bitmap
= wx
.BitmapFromXPMData(im
)
85 img
= wx
.ImageFromBitmap(bitmap
)
86 bitmap
= wx
.BitmapFromImage(img
.Scale(bitmap
.GetWidth() * scale
, bitmap
.GetHeight() * scale
))
87 bitmaps
.append(bitmap
)
88 wx
.lib
.throbber
.Throbber
.__init
__(self
, parent
, -1, bitmaps
, frameDelay
= delay
)
89 self
.SetToolTipString(tooltip
)