setting a background image of panel managed by an AUI manager

Dear wxpython users,

I have an application that contains an aui notebook. Each page of this notebook hosts a panel that should be managed by an aui manager.
When I try to set a background image to this panel the image is not displayed and the event wx.EVT_ERASE_BACKGROUND is event not

fired. You will find below a snippet that reproduces this (unwanted) behaviour.

import wx
import wx.aui as wxaui

class MyPanel(wx.Panel):

def \_\_init\_\_\(self,parent\):
    wx\.Panel\.\_\_init\_\_\(self, parent=parent\)

    self\.SetBackgroundStyle\(wx\.BG\_STYLE\_CUSTOM\)
    self\.Bind\(wx\.EVT\_ERASE\_BACKGROUND, self\.OnEraseBackground\)
    
    \# IF YOU COMMENT THOSE TWO LINES, IT WORKS
    self\.\_mgr = wxaui\.AuiManager\(self\)
    self\.\_mgr\.Update\(\)

def OnEraseBackground\(self, evt\):
    
    \# yanked from ColourDB\.py
    dc = evt\.GetDC\(\)

    if not dc:
        dc = wx\.ClientDC\(self\)
        rect = self\.GetUpdateRegion\(\)\.GetBox\(\)
        dc\.SetClippingRect\(rect\)
    dc\.Clear\(\)
    bmp = wx\.Bitmap\("image\.jpg"\)
    dc\.DrawBitmap\(bmp, 0, 0\)

class MainPanel(wx.Panel):

def \_\_init\_\_\(self, parent\):
    """Constructor"""
    wx\.Panel\.\_\_init\_\_\(self, parent=parent\)
    
    self\.frame = parent

    hSizer = wx\.BoxSizer\(wx\.HORIZONTAL\)

    self\.\_notebook = wxaui\.AuiNotebook\(self\)
    self\.\_notebook\.AddPage\(MyPanel\(self\),"toto"\)

    hSizer\.Add\(self\.\_notebook, 1, wx\.EXPAND\)
    self\.SetSizer\(hSizer\)

class MainFrame(wx.Frame):

def \_\_init\_\_\(self\):
    """Constructor"""
    wx\.Frame\.\_\_init\_\_\(self, None, size=\(600,450\)\)
    panel = MainPanel\(self\)        
    self\.Center\(\)

class Main(wx.App):

def \_\_init\_\_\(self, redirect=False, filename=None\):
    """Constructor"""
    wx\.App\.\_\_init\_\_\(self, redirect, filename\)
    dlg = MainFrame\(\)
    dlg\.Show\(\)

if __name__ == "__main__":
app = Main()
app.MainLoop()

Would you have any idea about what is wrong with my code and how I can solve this ?

thanks a lot

Eric

ยทยทยท

Sent from my LG Mobile
Pellegrini Eric <ericpellegrini@yahoo.fr> wrote:

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.