Transparent Controls

Is there a way to make controls transparent? Like RadioBoxes and StaticText and CheckBoxes.
I want to use a bitmap as a background for a bunch of controls and the problem I’m having is that the controls paint their background. For example the background of the Radiobox is entirely white and I want to be able to see through it.

I think this question has been answered before, but somehow I cannot find the answer…

Thank you in advance.
Peter.
wx 2.6.3.2 on py 2.4 on WinXP SP2

Peter Damoc wrote:

Is there a way to make controls transparent? Like RadioBoxes and StaticText and CheckBoxes.
I want to use a bitmap as a background for a bunch of controls and the problem I'm having is that the controls paint their background. For example the background of the Radiobox is entirely white and I want to be able to see through it.

On Windows you can usually do this by catching the EVT_ERASE_BACKGROUND event and doing nothing in the handler, but this can sometimes cause repaint issues for the foreground, depending on the type of the control.

Another approach to take that may work for your situation is to draw the background yourself in the control's EVT_ERASE_BACKGROUND handler. Just calculate the portion of the background image that would be obscured and draw it to the DC provided by the event.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Peter Damoc wrote:

Is there a way to make controls transparent? Like RadioBoxes and StaticText and CheckBoxes.
I want to use a bitmap as a background for a bunch of controls and the problem I'm having is that the controls paint their background. For example the background of the Radiobox is entirely white and I want to be able to see through it.

I wrote a small program to create a front-end menu for a software installation CD with the option to include a background image and the menu text showing transparently - see attached. But I don't know if the technique can be extended to other controls like radio- and check- boxes.

cdMenu.zip (357 KB)

···

--
Regards,
David Hughes

this is what I thought too… but it doesn’t work
here is the code I used to try it… maybe I’m missing something

import wx

class DrawPanel(wx.Panel):
def init(self, parent):

    wx.Panel.__init__(self, parent)
    self.rb = wx.RadioBox(self, label="Some RadioBox", choices=["one", "two", "three"])
    # self.rb.Bind(wx.EVT_ERASE_BACKGROUND

, self.DoNothing)
self.rb.Bind(wx.EVT_ERASE_BACKGROUND, self.RedrawBack)
self.Bind(wx.EVT_PAINT, self.OnPaint)

def DoNothing(self, evt): pass
def RedrawBack(self, evt):
    dc = evt.GetDC()
    dc.DrawCircle(100, 100,100)
    evt.Skip()
   
def OnPaint(self, evt):
    dc = wx.PaintDC(self)
    dc.DrawCircle(100, 100,100)
    evt.Skip()

app = wx.App(0)
frame = wx.Frame(None)

DrawPanel(frame)
frame.Show()

app.MainLoop()

···

On 7/18/06, Robin Dunn robin@alldunn.com wrote:

On Windows you can usually do this by catching the EVT_ERASE_BACKGROUND
event and doing nothing in the handler, but this can sometimes cause
repaint issues for the foreground, depending on the type of the control.

Thanks David… nice fade in effect :wink:
Unfortunately you draw your control entirely and the interaction is simple (mouse in/out and click)… but reconstructing a radiobox… is not that simple :wink:

Peter.

···

On 7/19/06, David Hughes dfh@forestfield.co.uk wrote:

I wrote a small program to create a front-end menu for a software
installation CD with the option to include a background image and the
menu text showing transparently - see attached. But I don’t know if the
technique can be extended to other controls like radio- and check- boxes.