Search code examples
pythonuser-interfacewxwidgets

how to change page selection in wxNotebook or wxChoicebook?


Is there any way to change the page of a wxNotebook or wxChoicebook programmatically? Looking at the documentation I would have thought that wxChoicebook::ChangeSelection was the way to go, or wxChoicebook::SetSelection if I want the page changing/changed events to be sent. However, I don't know what these functions expect as input. The seem to require a size_t type input, but all I get from a GetSelection is an integer. I'm working in wxPython if that helps.


Solution

  • I think you should be using wxNotebook::ChangeSelection, and in that function the size_t parameter refers to the integer index of the notebook page you would like to switch to. ChangeSelection(0) would change to the first notebook page, ChangeSelection(1) to the second, and so on.

    I did test this in code, and it works. I use wxWidgets with C++ though, I didn't test wxPython. Hope that helps!