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