Quantcast

Transparent Panels

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Transparent Panels

Jonathan Viney-4
Hi,

I was wondering if it is possible to to transparent panels with wxPython, here is what I am trying to do...

I have a background panel on which I want to draw a background image. On this background panel I have 3 other panels which I want to be transparent (apart from the text on them) so that I can see the image on the background panel. Is it possible to do this with wxPython, or am I going about this the wrong way.

I couldn't see any obvious way to do it. I tried using the wx.TRANSPARENT_WINDOW style on the panels, but that didn't seem to make any difference.

Do I have to do something like finding the location of each panel on the background panel and then redrawing that part of the image on this panel? That might be possible...

Any help or nudges in the right direction would be appreciated.

Cheers,
Jonathan



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Transparent Panels

Robin Dunn
Jonathan Viney wrote:

> Hi,
>
> I was wondering if it is possible to to transparent panels with
> wxPython, here is what I am trying to do...
>
> I have a background panel on which I want to draw a background image.
> On this background panel I have 3 other panels which I want to be
> transparent (apart from the text on them) so that I can see the image
> on the background panel. Is it possible to do this with wxPython, or
> am I going about this the wrong way.
>
> I couldn't see any obvious way to do it. I tried using the
> wx.TRANSPARENT_WINDOW style on the panels, but that didn't seem to
> make any difference.
>
> Do I have to do something like finding the location of each panel on
> the background panel and then redrawing that part of the image on
> this panel? That might be possible...
>
> Any help or nudges in the right direction would be appreciated.

Transparency is handled differently on the different platforms so it is
not really possible to wrap a consistent cross-platform API around it.
For example, on Windows the erase/paint of the background is a separate
step than the painting of the window contents, and so it can be
overridden with an event handler.  On GTK the background erase event is
simulated and sent just before the paint event, however the background
has probably already been painted by the X-server with the bg colour of
the window.  Also some controls on wxGTK are not real windows but are
just drawn on the parent, perhaps with some transparency.  On Mac pretty
much everything is transparent by default, unless it is opaque.  ;-)

So in the end, it really depends on what you need to do, but usually
avoiding layering like this is best.

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



Loading...