[wxPython-users] Drawing panel backgrounds with widgets visible on top

Frank Aune Frank.Aune at broadpark.no
Wed Oct 17 22:18:35 PDT 2007


On Wednesday 17 October 2007 16:11:01 Chris Mellon wrote:
> You'll want the wx.FULL_REPAINT_ON_RESIZE flag when you're doing this
> sort of full-area drawing.

Just tried the code provided by Andrea on Win32, and it did not work as 
expected on this plattform. I managed to tweak it slightly, but if I place 
wx.StaticText labels into the panel where the background is painted, the 
entire label area will block the image below.

On GNU/Linux this works as expected, and the area of the statictext labels 
does not block the background image.

This is the semi-working code, which works 100% under GNU/Linux, but on win32 
the area of statictext labels placed on top of the background will block the 
underlying part of the background image:
---
 def OnErase(self, event):
        dc = event.GetDC()
        if not dc or sys.platform == 'win32':
            dc = wx.ClientDC(self.panel)
        
        panelSize = self.panel.GetClientSize()

        bmpWidth, bmpHeight = self.theBitmap.GetWidth(), 
self.theBitmap.GetHeight()
        xPos = (panelSize.x - bmpWidth)/2
        yPos = (panelSize.y - bmpHeight)/2
        dc.DrawBitmap(self.theBitmap, xPos, yPos)

        event.Skip()
---

I had to do an event.Skip() on win32, and create the dc object explicitly - 
else the graphics was either totally screwed up, or the background image only 
displayed shortly while resizing the window and then disappearing instantly 
again.

If someone know what to do to fix this for win32, I would be very grateful. I 
don't have access to a win32 computer and it's really hard to debug stuff 
when you don't have access to the plattform and things just work on 
GNU/Linux.

Thank you very much for valued feedback so far!

-Frank




More information about the wxpython-users mailing list