[wxPython-users] transparent background for a panel widget
Christopher Barker
Chris.Barker at noaa.gov
Fri Jul 20 21:54:17 PDT 2007
Stephen M. Gava wrote:
>> Still it is possible to
>> make what you want by using EVT_ERASE_BACKGROUND event handler in
>> addition to EVT_PAINT, and draw a part of the parent's background image,
>> for example:
>>
>> def OnErase(self, evt):
>> dc = evt.GetDC()
>> dc.DrawBitmap(bg.GetSubBitmap(self.GetRect()), 0, 0)
This is probably the only way to do it. The fact is that wxWidgets
simply does not fully support transparent windows. That's because the
toolkit it wraps don't all support it, and certainly didn't years ago
when the design started -- maybe in the future.
> Hmm, ok, I'll give it a whirl. You can see how progressively more
> complex this is getting though.
I've kind of forgotten your original goal, but I'd think very carefully if:
You can just abandon the transparency -- it sounds like eye candy to me.
Or maybe using controls isn't the way to go at all -- you may be able to
just draw all of what you need on a single panel, capture the mouse
clicks and process them yourself.
As an example (and maybe it's useful) wx.lib.floatcanvas provides a
framework for drawing objects on a Canvas, binding mouse events to those
objects (including MOUSE_ENTER, etc. Give it a look see. There is a demo
in the wxPython demo, and more as part of the distribution you can find at:
> http://morticia.cs.dal.ca/FloatCanvas
You can poke through the SVN version to get just the demos if you want.
they are all stand-alone, and almost all of them will run with the
latest wx.lib version.
> It'd be nice if window background
> transparency just worked by default, by setting an attribute or at least
> by honouring the use of a transparent background brush..
I thought I explained that -- the problem is not the Brush -- that
works, the problem is your first point -- transparent windows simple are
not supported.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
More information about the wxpython-users
mailing list