Page is not really changed when EVT_NOTEBOOK_PAGE_CHANGED happened

Hi,

I got a problem when dealing with event of Notebook.

I bind EVT_NOTEBOOK_PAGE_CHANGED of notebook event to my handler. The
document said

"The page selection was changed. Processes a
wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED event. "

But I found that, when the handler is invoked, the notebook did't
really changed the page, and if you don't skip the event, the page is
not changed indeed. At this moment, if you call GetCurrentPage of
notebook, you get None.

That's so strange, why the notebook doesn't act just like document
said, invoked EVT_COMMAND_NOTEBOOK_PAGE_CHANGED when the page is
"really" changed? Why I have to skip the event so that the page is
changed? So, how can I do something that I want to do when the page is
"really changed"?

Thanks.
Victor Lin.

Victor,

···

On Aug 12, 7:42 am, Victor Lin <borns...@gmail.com> wrote:

Hi,

I got a problem when dealing with event of Notebook.

I bind EVT_NOTEBOOK_PAGE_CHANGED of notebook event to my handler. The
document said

"The page selection was changed. Processes a
wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED event. "

But I found that, when the handler is invoked, the notebook did't
really changed the page, and if you don't skip the event, the page is
not changed indeed. At this moment, if you call GetCurrentPage of
notebook, you get None.

That's so strange, why the notebook doesn't act just like document
said, invoked EVT_COMMAND_NOTEBOOK_PAGE_CHANGED when the page is
"really" changed? Why I have to skip the event so that the page is
changed? So, how can I do something that I want to do when the page is
"really changed"?

Thanks.
Victor Lin.

It works correctly for me in the demo on Windows XP. I have the
2.8.10.1 version of the demo. Have you tried the demo on your machine?
You might try adding the Widget Inspection Tool to your program and
use that to trace the events that are firing as well.

- Mike

Victor Lin wrote:

Hi,

I got a problem when dealing with event of Notebook.

I bind EVT_NOTEBOOK_PAGE_CHANGED of notebook event to my handler. The
document said

"The page selection was changed. Processes a
wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED event. "

But I found that, when the handler is invoked, the notebook did't
really changed the page, and if you don't skip the event, the page is
not changed indeed. At this moment, if you call GetCurrentPage of
notebook, you get None.

Use the event object's GetSelection to get the index of the newly selected page (and GetOldSelection to get the one you just switched from.)

···

--
Robin Dunn
Software Craftsman