Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wxpython auinotebook close tab event

What event is used when I close a tab in an auinotebook? I tested with EVT_AUINOTEBOOK_PAGE_CLOSE(D). It didn't work.

I would also like to fire a right click on the tab itself event.

Where can I find all the events that can be used with the aui manager/notebook? Might just be my poor searching skills, but I can't find any lists over the different events that exist, not for mouse/window events either. It would be really handy to have a complete list.

#!/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('Page 1')
        self.new_panel('Page 2')
        self.new_panel('Page 3')

        self.nb.Bind(wx.EVT_AUINOTEBOOK_PAGE_CLOSED, self.close)

    def new_panel(self, nm):
        pnl = wx.Panel(self)
        pnl.identifierTag = nm
        self.nb.AddPage(pnl, nm)
        self.sizer = wx.BoxSizer()
        self.sizer.Add(self.nb, 1, wx.EXPAND)
        self.SetSizer(self.sizer)

    def close(self, event):
        print 'closed'

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

like image 447
Orjanp Avatar asked Mar 09 '09 10:03

Orjanp


1 Answers

This is the bind command you want:

self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSED, self.close, self.nb)

To detect a right click on the tab (e.g. to show a custom context menu):

self.Bind(wx.aui.EVT_AUINOTEBOOK_TAB_RIGHT_DOWN, self.right, self.nb)

Here's a list of the aui notebook events:

EVT_AUINOTEBOOK_PAGE_CLOSE
EVT_AUINOTEBOOK_PAGE_CLOSED
EVT_AUINOTEBOOK_PAGE_CHANGED
EVT_AUINOTEBOOK_PAGE_CHANGING
EVT_AUINOTEBOOK_BUTTON
EVT_AUINOTEBOOK_BEGIN_DRAG
EVT_AUINOTEBOOK_END_DRAG
EVT_AUINOTEBOOK_DRAG_MOTION
EVT_AUINOTEBOOK_ALLOW_DND
EVT_AUINOTEBOOK_DRAG_DONE
EVT_AUINOTEBOOK_BG_DCLICK
EVT_AUINOTEBOOK_TAB_MIDDLE_DOWN
EVT_AUINOTEBOOK_TAB_MIDDLE_UP
EVT_AUINOTEBOOK_TAB_RIGHT_DOWN
EVT_AUINOTEBOOK_TAB_RIGHT_UP

From: {python folder}/Lib/site-packages/{wxpython folder}/wx/aui.py

like image 59
Ryan Ginstrom Avatar answered Nov 12 '22 05:11

Ryan Ginstrom