Commit 15c980cf authored by Duane Johnson's avatar Duane Johnson

Fix black background / transparency issue in Windows/Linux

parent 3722b11a
...@@ -111,13 +111,21 @@ class BufferedCanvas(wx.Panel): ...@@ -111,13 +111,21 @@ class BufferedCanvas(wx.Panel):
Causes the canvas to be updated. Causes the canvas to be updated.
""" """
dc = wx.MemoryDC() dc = wx.MemoryDC()
width,height = self.GetClientSizeTuple() width,height = self.getWidthHeight()
self.backbuffer = wx.EmptyBitmap(width,height) self.backbuffer = wx.EmptyBitmapRGBA(width,height,alpha=0)
dc.SelectObject(self.backbuffer) dc.SelectObject(self.backbuffer)
dc.BeginDrawing() dc.BeginDrawing()
self.draw(dc) self.draw(dc)
dc.EndDrawing() dc.EndDrawing()
self.flip() self.flip()
def getWidthHeight(self):
width,height = self.GetClientSizeTuple()
if width == 0:
width = 1
if height == 0:
height = 1
return (width, height)
## ##
## Event handlers ## Event handlers
...@@ -131,13 +139,9 @@ class BufferedCanvas(wx.Panel): ...@@ -131,13 +139,9 @@ class BufferedCanvas(wx.Panel):
def onSize(self, event): def onSize(self, event):
# Here we need to create a new off-screen buffer to hold # Here we need to create a new off-screen buffer to hold
# the in-progress drawings on. # the in-progress drawings on.
width,height = self.GetClientSizeTuple() w, h = self.getWidthHeight()
if width == 0: self.buffer = wx.EmptyBitmapRGBA(w, h, alpha=0)
width = 1 self.backbuffer = wx.EmptyBitmapRGBA(w, h, alpha=0)
if height == 0:
height = 1
self.buffer = wx.EmptyBitmap(width,height)
self.backbuffer = wx.EmptyBitmap(width,height)
# Now update the screen # Now update the screen
self.update() self.update()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment