Interactions between pages of a notebook - Howto ?

I've run across similar situations and what I've done is to have the
widget in the notebook send an update message to the parent of the
notebook (probably your wx.Frame) which then propagates the change to
all of the notebooks, which each update their own widgets. To make
this more efficient, I tagged the messge with what type of change was
made, i.e. should it only update the outputs, should it force all
widgets to reload their values, etc. Don't try to hard-code which
widget should change which other widgets (i.e., the "number of items"
widget changes the "price" and "tax" widgets) as it becomes a
nightmare for maintenance as the number of widgets grows.

If you are dealing with a large number of TextCtrl widgets, watch out
for updating them- they are very slow. You can mitigate the effects
by only updating the values on the currently active notebook pages and
setting a type of dirty bit on the non-active pages, and then
reloading pages as they are activated.

As Josiah stated, be careful of what triggers the update messages-
with TextCtrl widgets, whenever you change their value, even through
SetValue, it triggers a EVT_TEXT event, so it is very easy to create
infinite loops of widgets sending update messages.

Hope this helps,

David

ยทยทยท

On 4/2/07, Josiah Carlson <jcarlson@uci.edu> wrote:

"DomDom" <BestDomDom@neuf.fr> wrote:
> Hello,
>
> I have a frame which contains a notebook, created in a class called Myframe.
> The 9 pages of the notebook are created by one class called PageNum,
> whose argument is the page number (so that I create the different
> pages automatically by calling PageNum(1) etc).
>
> I want that when a TextCtrl of Page 1 is modified by the user, a
> TextCtrl in page 2 (or 3...) be modified automatically.
> My problem is to be as efficient as possible because I have several
> (many!) widgets to modify on each page.
> And I don't want to drown under lines of code...!!

My first suggestion is not to do it, there are rarely good reasons to
duplicate data in a GUI unless you are offering different views of the
data (different kinds of charts, etc.).

My second suggestion is to use wx.lib.pubsub . Each instance can
subscribe to the changes it wants to see 'modified.PageNum.5' for
example, and each page can send notifications when they change. Note
that if you have something like 'page 1 change causes page 2 to change'
and 'page 2 change causes page 1 to change', you can run into a
situation where you end up with infinite updates if you are not careful.

- Josiah

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org