Intra App Communication

Mark Erbaugh mark at microenh.com
Sun Dec 2 13:50:01 PST 2007


What is the wxPython way of communicating between different frames
(windows) in the same app.  Here's what I am trying to achieve.

I have a frame that displays a database record in read-only mode. If the
user clicks on the EDIT button I want to create a new frame that will
allow the user to edit that record, or activate an existing edit frame
if one exists.  When a record is updated, I want any frames displaying
that particular record to be notified that their record has changed so
they can update themselves.  I'd prefer to keep the appropriate logic
within each frame rather than trying to design some sort of 'master
controller' to keep track of things.  Note: I would like the user to be
able to freely close frames.  For example, from viewing a record, they
could click on the EDIT button to open a new edit frame, then close (or
not close) the read-only frame.  They could close the edit frame without
updating the data. The could click on the read-only frame's EDIT button
a second time, before which they could have closed or not-closed the
edit frame.  The could post the update from the edit frame after having
closed or not closed the read-only frame.  They could navigate the
read-only frame to a different record.

Here's what I think I would like to do.

1) The user is viewing a record in the read-only frame and clicks on the
EDIT button. This frame sends out a general message asking "are there
any edit frames currently editing this record?" If no frames respond,
the read-only frame would create a new edit frame. If a frame does
respond, the read-only frame activates it by bringing it to the front
and giving it the focus (and restoring it if it had been minimized).

2) The user clicks update on the edit frame. This frame sends out a
general message "any frame viewing this record, the data has been
updated".  It is acceptable for there to be zero or more frames that are
viewing the given record.

Thanks,
Mark





More information about the wxpython-users mailing list