This demo app demonstrate offline rendering of bitmaps using
wx.GraphicsContext is buggy.
If you are using wx.EmptyBitmapRGBA(100, 100) to render a bitmap then
bitmap is coming out completely empty. (not event black)
If you are using wx.EmptyBitmap(100, 100) to render a bitmap then
bitmap is full of garbage. (see attached image)
Actually I created this demo app to show that in my application
transparency is replaced by pure black color, eventually I have found
two more problems when I created this app.
The description in demo->Using Images>Image Alpha says something about
this on GTK platform but I am seeing transparency properly on my
machine, means it has been fixed.
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
self.prepareOfflineBitmap()
self.Bind(wx.EVT_PAINT, self.OnPaint)
def prepareOfflineBitmap(self):
font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
self.bitmap = wx.EmptyBitmapRGBA(100, 100)#wx.EmptyBitmap(100,
100)
mdc = wx.MemoryDC(self.bitmap)
ctx = wx.GraphicsContext.Create(mdc)
ctx.DrawText("wxPython Rocks!!!", 0, 45)
ctx.SetBrush(wx.Brush("red"))
ctx.DrawRectangle(10,10,25,25)
mdc.SelectObject(wx.NullBitmap)
del mdc
def OnPaint(self, evt):
dc = wx.PaintDC(self)
gc = wx.GraphicsContext.Create(dc)
gc.PushState()
gc.Translate(0,0)
gc.DrawBitmap(self.bitmap, 0, 0, 100, 100)
gc.PopState()
You can use demo app to run this application. I ripped the code from
demo->Miscellaneous->GraphicsContext.
Prashant
Note: I am not able to send mails from my mail account and keep
getting failure notice.
Cannot post hyper link of image. Post is getting rejected
may be you can get the same
results from the code.
#---- System Information ----#
GUI2Exe Version: 0.5.0
Operating System: Linux 2.6.31-14-generic i686
Python Version: 2.6.4rc2 (r264rc2:75497, Oct 20 2009, 02:55:11)
[GCC 4.4.1]
wxPython Version: 2.8.10.1 (gtk2-unicode)
wxPython Info: (__WXGTK__, wxGTK, unicode, gtk2, wx-assertions-off,
SWIG-1.3.29)
Python Encoding: Default=UTF-8 File=UTF-8
wxPython Encoding: utf-8
System Architecture: 32bit i686
Byte order: little
Frozen: False
#---- End System Information ----#