I’m trying to mimic the MacOS style of a semi-transparent left panel and solid right panel as seen in applications like Xcode. So far, I am able to make the whole frame transparent but can’t manage to make a single panel transparent.
Thanks. Got that part where I can make the whole frame transparent. In my case I put a splitter control with two panels: left and right but only want the left panel transparent not the right. Can’t seem to do that part.
I made a change to the MyPanel.OnPaint() method so the TextCtrl has a white background:
def OnPaint(self, event):
dc = wx.ClientDC(self)
panel = event.GetEventObject()
w, h = panel.GetSize()
# print(f"OnPaint() {w} x {h}")
# Create an all WHITE image
data = bytearray((255, 255, 255) * w * h)
img = wx.Image(w, h, data)
# Convert to bitmap
bmp = wx.Bitmap(img)
# Mask uses BLACK for transparent pixels
mask = wx.Mask(bmp, wx.BLACK)
# Apply mask to bitmap which should then be opaque
bmp.SetMask(mask)
dc.DrawBitmap(bmp, 0, 0, True)
I was afraid that might be the case. From what I have been reading, transparency is an area that has some of the more noticeable differences on the various platforms. Unfortunately I can only test on Linux.
I got the idea to use a Mask for this implementation after reading a couple of threads on this forum where it had been mentioned:
well, a mask is nottransparency: the latter may be stored in a permanent file whereas the first always needs some bitwise operation (that’s were some photographers turn into maniacs, or so)