aui.EVT_AUINOTEBOOK_PAGE_CLOSED does not fire.

Have the following sample. Is is also available here: http://www.copypastecode.com/14169/

The problem is that when I click the x on the tab, the page_close event does not fire.

Does this work for others? Have tried to reinstall wxpython, but the problem did not go away.

Oerjan Pettersen

[code******************************]
#!/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')
    print self.nb.GetSelection()
    self.new_panel('Page 2')
    print self.nb.GetSelection()
    self.new_panel('Page 3')
    print self.nb.GetSelection()

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

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

    pnl.Bind(wx.EVT_LEFT_DOWN, self.click)

  def click(self, event):
    print 'Mouse click'
    print self.nb.GetSelection()
    print self.nb.GetPageText(self.nb.GetSelection())

  def close(self, event):
    print 'closed'
    print self.nb.GetSelection()

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

Ørjan Pettersen wrote:

Have the following sample. Is is also available here: http://www.copypastecode.com/14169/

The problem is that when I click the x on the tab, the page_close event does not fire.

Does this work for others? Have tried to reinstall wxpython, but the problem did not go away.

I am on Win 7 with
# Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)]
# wxPython 2.8.10.1, Boa Constructor 0.6.1

and I see the close, i.e. the print output is this:
0
1
2
closed
1

You might also want to look at Andrea's implementation of AUI, it is in wx.lib.agw.aui (currently it would be best to get it from SVN as there are a few corrections in there which have not made it into a release yet).

Werner

werner wrote:

�rjan Pettersen wrote:

Have the following sample. Is is also available here: http://www.copypastecode.com/14169/

The problem is that when I click the x on the tab, the page_close event does not fire.

Does this work for others? Have tried to reinstall wxpython, but the problem did not go away.

I am on Win 7 with
# Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)]
# wxPython 2.8.10.1, Boa Constructor 0.6.1

and I see the close, i.e. the print output is this:
0
1
2
closed
1

You might also want to look at Andrea's implementation of AUI, it is in wx.lib.agw.aui (currently it would be best to get it from SVN as there are a few corrections in there which have not made it into a release yet).

Werner

Strange. I wonder what I have done to make it behave like this. Haven't found any other events that don't work.

Thanks for the tip on Andrea's AUI.

Orjanp