What event handler is the call to onUpdate coming from? If it's one of the choicebook events then it could easily be a case of the changes you are making are triggering new events. There may be a more appropriate event to do the change from, or you may just have to guard against recursion yourself.
···
On 9/27/12 3:59 PM, DanStuewe wrote:
I would like to have a choicebook in which the choices are dynamic. I
attempted to define (in __init__) the choicebook with pages A and B and
then in an "onUpdate" method, page B can be removed and page C will be
added. When I used the choicebook.RemovePage method I see
strange behavior in which my onUpdate method gets called again
(seemingly recursively) a number of times and once the code gets on its
way, the list of choices is not complete. Which leads to a few
questions...Should this be the proper way to have the choice of pages
be dynamic in a choicebook? or is there a better solution? If the
former, any ideas on what might be causing this behavior? If the latter,
what is the better solution? (BTW, Python 2.7.3, wx 2.8.12.1)
Thanks Robin. I think your question opened the flood gates. I believe my problem isn’t with the RemovePage, but with the subsequent AddPage which triggers the EVT_CHOICEBOOK_PAGE_CHANGED event which is bound to a method which calls the onUpdate method and so on and so on…
I believe my solution will be to be more judicious on when I want to update the whole thing and when I only want to update certain portions of the frame.
Thanks again.
···
On Thursday, September 27, 2012 5:59:47 PM UTC-7, Robin Dunn wrote:
On 9/27/12 3:59 PM, DanStuewe wrote:
I would like to have a choicebook in which the choices are dynamic. I
attempted to define (in init) the choicebook with pages A and B and
then in an “onUpdate” method, page B can be removed and page C will be
added. When I used the choicebook.RemovePage method I see
strange behavior in which my onUpdate method gets called again
(seemingly recursively) a number of times and once the code gets on its
way, the list of choices is not complete. Which leads to a few
questions…Should this be the proper way to have the choice of pages
be dynamic in a choicebook? or is there a better solution? If the
former, any ideas on what might be causing this behavior? If the latter,
what is the better solution? (BTW, Python 2.7.3, wx 2.8.12.1)
Let me know if more information is needed.
What event handler is the call to onUpdate coming from? If it’s one of
the choicebook events then it could easily be a case of the changes you
are making are triggering new events. There may be a more appropriate
event to do the change from, or you may just have to guard against
recursion yourself.