AuiNotebook, where did the event happend
Question: How can I find out from which AuiNotebook page an event occurred?

EDIT: Sorry about that. Here are a code example. How do I find the notebook
page from witch the mouse was clicked in?

    
    
    #!/usr/bin/python
    
    #12_aui_notebook1.py
    
    import wx
    import wx.lib.inspection
    
    class MyFrame(wx.Frame):
        def __init__(self, *args, **kwds):
        	wx.Frame.__init__(self, *args, **kwds)
    
        	self.nb = wx.aui.AuiNotebook(self)
    
        	self.new_panel('Pane 1')
        	self.new_panel('Pane 2')
        	self.new_panel('Pane 3')
    
        def new_panel(self, nm):
        	pnl = wx.Panel(self)
        	self.nb.AddPage(pnl, nm)
        	self.sizer = wx.BoxSizer()
        	self.sizer.Add(self.nb, 1, wx.EXPAND)
        	self.SetSizer(self.sizer)
    
        	pnl.Bind(wx.EVT_LEFT_DOWN, self.click)
    
        def click(self, event):
        	print 'Mouse click'
                #How can I find out from witch page this click came from?
    
    
    class MyApp(wx.App):
        def OnInit(self):
        	frame = MyFrame(None, -1, '12_aui_notebook1.py')
        	frame.Show()
        	self.SetTopWindow(frame)
        	return 1
    
    if __name__ == "__main__":
        app = MyApp(0)
    #    wx.lib.inspection.InspectionTool().Show()
        app.MainLoop()
    

Oerjan Pettersen


Answer: For a mouse click you can assume the current selected page is the one that got
the click. I added a few lines to your code. See comments

    
    
    def new_panel(self, nm):
        pnl = wx.Panel(self)
        # just to debug, I added a string attribute to the panel
        # don't you love dynamic languages? :)
        pnl.identifierTag = nm   
        self.nb.AddPage(pnl, nm)
        self.sizer = wx.BoxSizer()
        self.sizer.Add(self.nb, 1, wx.EXPAND)
        self.SetSizer(self.sizer)
    
        pnl.Bind(wx.EVT_LEFT_DOWN, self.click)
    
    def click(self, event):
        print 'Mouse click'
        # get the current selected page
        page = self.nb.GetPage(self.nb.GetSelection())
        # notice that it is the panel that you created in new_panel
        print page.identifierTag
    

