Event or pubsub ?

Hi all,

I would have a question regarding the pubsub mechanism and if it the only way I should use in the following specific case.

I have an application where the user can select different kind of analysis from a menu. When an analysis is selected this pops up

a frame with:

  • the analysis-specific widgets necessary for setting up the analysis. They will differ from one analysis to another.

  • an additional set of buttons to cancel/save/run the analysis. They are common to all analysis.

In that context, I would like to implement the frame hosting the analysis as a kind of container/factory that just implements the common actions (cancel/run/save)

and a generic analysis widgets builder. I think that for a proper design NO analysis-specific implementations should be in the frame.

Here comes my problem.

The change in the value of one analysis widget should trigger the update of the other ones. My first idea was to use custom events in order that when

one widget is changed it sends an event captured by the other widgets sensitive to it. But I failed to find a way for widget A to post an event DIRECTLY

received and processed by widget B without passing by the frame. I do not want to pass by the frame because that would mean adding some bindings in the frame

hence losing its generic aspect.

The only way I found to solve that problem is to use the pubsub mechanism. You will find enclosed a little script that does the job.

Can I (should I ?) avoid the
use of pubsub mechanism to perform such task ? Does my aformentionned design look strange/bad to you ?

thanks a lot

Eric

test.py (1.66 KB)

Can I (should I ?) avoid the use of pubsub mechanism to perform such
task ?

No. This is exactly the kind of thing that pubsub was made for.

Does my aformentionned design look strange/bad to you ?

No.

···

On 11/26/11 6:12 AM, Pellegrini Eric wrote:

--
Robin Dunn
Software Craftsman

Thanks Robin. Let’s go ahead and use pubsub !

Eric

···

De : Robin Dunn robin@alldunn.com
À : wxpython-users@googlegroups.com
Envoyé le : Dimanche 27 Novembre 2011 0h31
Objet : Re: [wxPython-users] Event or pubsub ?

On 11/26/11 6:12 AM, Pellegrini Eric wrote:

Can I (should I ?) avoid
the use of pubsub mechanism to perform such
task ?

No. This is exactly the kind of thing that pubsub was made for.

Does my aformentionned design look strange/bad to you ?

No.

– Robin Dunn
Software Craftsman
http://wxPython.org

– To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en