#----------------------------------------------------------------------
# auiNotebookDemo.py
#
# Created 12/01/2009
#
# Author: Mike Driscoll - mike@pythonlibrary.org
#
#----------------------------------------------------------------------

import wx
import wx.aui

class DemoPanel(wx.Panel):
    """
    This will be the first notebook tab
    """
    #----------------------------------------------------------------------
    def __init__(self, parent):
        """"""        
        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
        
        # create the AuiNotebook instance
        self.nb = wx.aui.AuiNotebook(self)
        self.nb.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED, self.onChange)
        self.currentSelection = wx.CallAfter(self.nb.GetSelection)
        
        # add some pages to the notebook
        for label in ['Page1','Page2','Page3', 'Page4']:
            page = wx.Panel(self.nb, -1,name=label)
            self.nb.AddPage(page,label) 
            
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.nb, 1, wx.EXPAND)
        self.SetSizer(sizer)
        
    #----------------------------------------------------------------------
    def onChange(self, event):
        """"""
        print self.currentSelection
        if self.currentSelection != None:
            print self.nb.GetPageText(self.currentSelection)
        self.currentSelection = self.nb.GetSelection()
        

########################################################################
class DemoFrame(wx.Frame):
    """
    Frame that holds all other widgets
    """

    #----------------------------------------------------------------------
    def __init__(self):
        """Constructor"""        
        wx.Frame.__init__(self, None, wx.ID_ANY, 
                          "AUI-Notebook Tutorial",
                          size=(600,400))
        panel = DemoPanel(self)                
        self.Show()
        
#----------------------------------------------------------------------
if __name__ == "__main__":
    app = wx.PySimpleApp()
    frame = DemoFrame()
    app.MainLoop()
