[wxPython-users] Interactions between pages of a notebook - Howto ?

Josiah Carlson jcarlson at uci.edu
Mon Apr 2 17:03:26 PDT 2007


"DomDom" <BestDomDom at 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





More information about the wxpython-users mailing list