I am drawing a bitmap with a transparency with DC on a transparent panel in
OnPaint. The code below works great on MacOS (meaning that I am able to
update the transparent panel on top and the underlying frame content shows
through).
MacOS:
<http://wxpython-users.1045709.n5.nabble.com/file/n5724803/macos.jpg>
On Windows, however, my bitmap does not draw and I lose the frame content
underneath (blank white frame), though the rectangle and text draw in the
OnPaint does work.
Windows:
<http://wxpython-users.1045709.n5.nabble.com/file/n5724803/windows.jpg>
I have tried wrapping my DC with GCDC as per [here][3]:
pdc = wx.PaintDC(self.panel)
dc = wx.GCDC(pdc)
but the result is the same.
Code:
class MyBrowser(wx.Frame):
def __init__(self, *args, **kwds):
wx.Frame.__init__(self, *args, **kwds)
sizer = wx.BoxSizer(wx.VERTICAL)
self.browser = wx.html2.WebView.New(self)
sizer.Add(self.browser, 1, wx.EXPAND, 10)
self.SetSizer(sizer)
self.winsize = 800
self.zoom = 1
self.SetSize((self.winsize, self.winsize))
self.SetMaxSize((self.winsize, self.winsize))
self.SetMinSize((self.winsize, self.winsize))
self.panel=wx.Panel(self, -1, style=wx.TRANSPARENT_WINDOW,
size=(self.winsize, self.winsize))
self.panel.Bind(wx.EVT_PAINT, self.OnPaint)
def OnPaint(self, evt):
#dc = wx.PaintDC(self.panel)
pdc = wx.PaintDC(self.panel)
dc = wx.GCDC(pdc)
dc.SetBrush(wx.Brush('#B1AFA3'))
dc.SetPen(wx.TRANSPARENT_PEN)
dc.DrawRectangle(0, 0, 145, 90)
dc.DrawText('Wind speed: ' + '{:.2f}'.format(windspd), 14, 8)
angle = (360.0 - winddir) + 90.0
if angle >= 360.0:
angle = 0.0
if 0.0 < angle < 180.0:
dc.DrawRotatedText('<---', 80, 72, angle)
else:
dc.DrawRotatedText('<---', 80, 42, angle)
lonperpix = self.lonperpix[0]
latperpix = self.latperpix[0]
self.pixx = (self.winsize/2) + ((lon-self.lon1[0])/lonperpix)
self.pixy = (self.winsize/2) - ((lat-self.lat1[0])/latperpix)
airplane1 = wx.Image('/Users/Downloads/x_Fighter.png')
airplane2 = airplane1.Rotate(-(math.radians(heading)), (16, 16))
dc.DrawBitmap(wx.BitmapFromImage(airplane2), self.pixx-16, self.pixy-16)
self.panel.Refresh()
Thanks in advance for any possible multi-platform strategies.
···
--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/wxPython-transparency-behavior-MacOS-vs-Windows-tp5724803.html
Sent from the wxPython-users mailing list archive at Nabble.com.