I'm using Python 2.3.4 and wxPython 2.5.2.8 on Windows XP SP2 and am noticing some inconsistent behavior with the EVT_NOTEBOOK_PAGE_CHANGING event.
When I use Ctrl-Tab to switch between pages, the event object's GetOldSelection() and GetSelection() methods return what I would expect them to: the page I'm moving away from and the page I'm moving to.
However, when I use the mouse to switch to a page, both GetOldSelection() and GetSelection() return the same thing: the page that I'm moving away from.
Is this expected? Since EVT_NOTEBOOK_PAGE_CHANGING is supposed to be used to determine if the current page is valid before moving on, I can understand not making the page we're moving to available. I just find it odd that it *is* available when using the keyboard but not when using the mouse.
I'm using Python 2.3.4 and wxPython 2.5.2.8 on Windows XP SP2 and am noticing some inconsistent behavior with the EVT_NOTEBOOK_PAGE_CHANGING event.
When I use Ctrl-Tab to switch between pages, the event object's GetOldSelection() and GetSelection() methods return what I would expect them to: the page I'm moving away from and the page I'm moving to.
However, when I use the mouse to switch to a page, both GetOldSelection() and GetSelection() return the same thing: the page that I'm moving away from.
There have been some discussions lately on wx-dev about how to make the notebook events more consistent on all platforms, but I don't recall off the top of my head what the result was. You might want to check the archives or to ask this question there.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
I'm using Python 2.3.4 and wxPython 2.5.2.8 on Windows XP SP2 and am
noticing some inconsistent behavior with the EVT_NOTEBOOK_PAGE_CHANGING
event.
When I use Ctrl-Tab to switch between pages, the event object's
GetOldSelection() and GetSelection() methods return what I would expect
them to: the page I'm moving away from and the page I'm moving to.
However, when I use the mouse to switch to a page, both
GetOldSelection() and GetSelection() return the same thing: the page
that I'm moving away from.
Have a look at the attached program. It shows a work-around to your problem,
using EVT_LEFT_DOWN to detect a mouse click. It may work for you.
I'm using Python 2.3.4 and wxPython 2.5.2.8 on Windows XP SP2 and am
noticing some inconsistent behavior with the EVT_NOTEBOOK_PAGE_CHANGING
event.
When I use Ctrl-Tab to switch between pages, the event object's
GetOldSelection() and GetSelection() methods return what I would expect
them to: the page I'm moving away from and the page I'm moving to.
However, when I use the mouse to switch to a page, both
GetOldSelection() and GetSelection() return the same thing: the page
that I'm moving away from.
Have a look at the attached program. It shows a work-around to your problem,
using EVT_LEFT_DOWN to detect a mouse click. It may work for you.
HTH
Frank Millman
Thanks for this, I've been dealing with the same problem. However, I'm using wxPython 2.4, and I'm thinking the API changed for Notebook.HitTest()
Because when I run this, it just returns the value 10, whenever I click anywhere on the notebook.
Obviously 10 is not indexable, so I had to remove the [0] part. I thought maybe it was returning one of the flags, but I don't find any of the wx.NB_HITTEST_*. Only ones for LIST and TREE.
10 would be an invalid tab (since you only have 4), so what would it be returning?
I tried to look through all of the wx constants, and the only one that evaluates to 10 that makes any sense is wx.YES_NO, but that doesn't really make sense.