[wxpython-users] Background image in a panel for a newbie

Robin Dunn robin at alldunn.com
Wed May 14 15:21:19 PDT 2008


Raph wrote:
> Hello,
> 
> I have a frame and I display a background image in it, 
> using the code below. This works fine. Now, as I 
> would like to add buttons and other widgets, I'm adding
> a panel to the frame (see the line commented out at the
> bottom of the script) and my picture image.jpg gets
> reduce to a small square on the upper left side of the 
> frame.
> 
> What am I missing.

Adding the panel makes the frame have more than one direct child, so it 
is not doing its built-in feature of resizing a single child to fill the 
client area.  Even if it didn't do that it's not what you want anyway 
because the panel is not transparent.

Instead you can forget the backgroundImage window class and just give 
the panel a handler for the EVT_ERASE_BACKGROUND event and do the 
painting of the image there.  The demo has some samples of this you can 
use for reference.

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



More information about the wxpython-users mailing list