wxNotebook replace page instead of delete

I have notebook pages that contain several hundred widgets each, and I am trying to dynamically load the page when the user clicks the appropriate tab, as the UI cannot handle loading all the pages at once. When the program is launched, it builds empty wxWindow objects for each page, and as the user clicks on a tab, I want the tab to be populated. I have tried adding a DeletePage() followed by InsertPage in a handler for EVT_NOTEBOOK_PAGE_CHANGED, however both of these methods themselves generate that event, causing recursive page generation.

What I would like is a ReplacePage() method, or something similar that would just replace the wxWindow at page index n with a new page that I’ve created. Is there a way to do this? (I’m open to completely alternate solutions).

You might try EVT_NOTEBOOK_PAGE_CHANGING

Otherwise write your own function/method called ReplacePage, set some class/global variable there (i.e. self.isBeingReplaced=True), then in your DeletePage and InsertPage overloaded methods, detect if your variable is set and veto the event so the normal handlers don’t continue getting called.

Really though, why not just delete all the /contents/ of the tab, rather than the tab itself?

···

On Wednesday, July 2, 2014 1:37:07 PM UTC-7, Aaron Hill wrote:

I have notebook pages that contain several hundred widgets each, and I am trying to dynamically load the page when the user clicks the appropriate tab, as the UI cannot handle loading all the pages at once. When the program is launched, it builds empty wxWindow objects for each page, and as the user clicks on a tab, I want the tab to be populated. I have tried adding a DeletePage() followed by InsertPage in a handler for EVT_NOTEBOOK_PAGE_CHANGED, however both of these methods themselves generate that event, causing recursive page generation.

What I would like is a ReplacePage() method, or something similar that would just replace the wxWindow at page index n with a new page that I’ve created. Is there a way to do this? (I’m open to completely alternate solutions).

This is in effect what I am trying to do. I was unable to find a way to do that however. wxNotebook has no methods like SetPage or similar.

···

On Monday, 7 July 2014 14:51:11 UTC-4, Nathan McCorkle wrote:

Really though, why not just delete all the /contents/ of the tab, rather than the tab itself?

Aaron,
wx.NoteBook.GetPage returns a window - you can then do almost
anything with it including DestroyChildren and create all the new
content that you would like.
Gadget/Steve

···

On 08/07/14 15:00, Aaron Hill wrote:

    On Monday, 7 July 2014 14:51:11 UTC-4, Nathan McCorkle wrote:
          Really though, why not just delete all the /contents/

of the tab, rather than the tab itself?

      This is in effect what I am trying to do. I was unable to find

a way to do that however. wxNotebook has no methods like
SetPage or similar.

  You received this message because you are subscribed to the Google

Groups “wxPython-users” group.

  To unsubscribe from this group and stop receiving emails from it,

send an email to wxpython-users+unsubscribe@googlegroups.com.

  For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

To follow up on Gadget/Steve’s point, maybe Aaron would want to create a separate class like “NotebookPage”, which would be a wxPanel with all the hundreds* of widgets on it. Then, on each notebook page, he would have a hierarchy like this:

– Notebook

– Page as a blank wxPanel with a simple boxSizer

– an instance of his custom NotebookPage class

Then when he used .GetPage() he could Destroy() the NotebookPage on that panel, and then add a new instance of NotebookPage to the panel.

The reason I don’t just recommend putting this NotebookPage directly as the page of the notebook is this line in the documents for wxNotebook: “Do not explicitly delete the window for a page that is currently
managed by wxNotebook.”

(*does your UI really need hundreds of widgets within a single notebook page? That type of statement always strikes me as excessive from a user experience perspective).

···

On Tue, Jul 8, 2014 at 1:47 PM, Steve Barnes gadgetsteve@live.co.uk wrote:

On 08/07/14 15:00, Aaron Hill wrote:

    On Monday, 7 July 2014 14:51:11 UTC-4, Nathan McCorkle wrote:
          Really though, why not just delete all the /contents/

of the tab, rather than the tab itself?

      This is in effect what I am trying to do. I was unable to find

a way to do that however. wxNotebook has no methods like
SetPage or similar.

  You received this message because you are subscribed to the Google

Groups “wxPython-users” group.

  To unsubscribe from this group and stop receiving emails from it,

send an email to wxpython-users+unsubscribe@googlegroups.com.

  For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

Aaron,

wx.NoteBook.GetPage returns a window - you can then do almost

anything with it including DestroyChildren and create all the new
content that you would like.

Gadget/Steve

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.