[wxPython-users] Re: "Pushing" Data to Modules

Rich Shepard rshepard at appl-ecosys.com
Sat Dec 2 09:35:48 PST 2006


On Sat, 2 Dec 2006, Donn Ingle wrote:

> Rich, I have also recently being trying to grok the whole WVC/WVP thing
> and I ended-up making my own "thing" because I couldn't really find good
> examples and info relating to the pubsub stuff.

Donn,

   I have no problems with the concept(s); I've used that model in C for
years, even though it didn't have a name. I'd always have the UI code in one
.c file, the middleware in another .c file, and the database back end (if
one was needed) in yet another file. To me, that was intuitive and the only
way to go. However, python and the object-oriented model seems to make the
whole process much more complex, at least for those of us who didn't start
coding with it.

> Attached, is my shout() ----> Ear ()  code, FWIW. I included instructions
> on use in the file.

   Thank you.

> Perhaps my (inevitable) mistakes and misconceptions will help you (and me
> by flame :) ) learn about pusub.

   Well, I'm not about to flame anyone over anything.

   I am having difficulties reconciling your names (shout and ear) with the
publish and subscribe idea. It's strictly a terminology mis-match, and I
know that you can clear it up for me.

   In wx.lib.pubsub, a module/class that creates an event (for example, in my
application, having the DBtools() class open the embedded sqlite3 database
file) would "publish" the news to the entire application. Other
modules/classes could "subscribe" to read messages of interest to it (with
the same example, loading database values in the widgets of each notebook
page).

   When I started reading your remotecontrol.py, I thought that shout() was
equivalent to publish(), and that ear() was equivalent to subscribe(). As I
read further, it seemed that I had it backwards. Now, I'm not at all sure
what's happening. Nor, why the messages are numbered rather than using
strings; e.g., "file open."

   Seems to me that the biggest problem with our use of pubsub is the lack of
an actual implementation to examine. Reading the API docs and trying to
learn just how to implement the wx.lib.pubsub() and Publisher() classes is
like reading a man page to learn a tool. Man pages and API docs are great
syntax reminders when you know what you're doing, and why you're doing it,
but they don't teach the context.

   In the vast universe of working wxPython apps, there must be at least one
that uses these classes so we can learn how to use them for ourselves. No?

Rich

-- 
Richard B. Shepard, Ph.D.               |    The Environmental Permitting
Applied Ecosystem Services, Inc.(TM)    |            Accelerator
<http://www.appl-ecosys.com>     Voice: 503-667-4517      Fax: 503-667-8863




More information about the wxpython-users mailing list