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()
