OOP Newbie mixing COM, wxPython, BOA

Mojo mojo at geofinity.com
Wed Feb 13 04:10:48 CET 2002


"Jeff Shannon" <jeff at ccvcorp.com> wrote in message
news:3C687007.4ACF94EE at ccvcorp.com...
<snip>
> What you should do, is instead of making the Jabber object be global to
your
> VpFrame module, you should encapsulate its creation into a function.  Have
your
> frame call this function in its __init__(), and then save the reference on
the
> frame.  At this point, you will also want to stick a reference to the
frame onto
> the Jabber object.

Yep, that did it.   I kept thinking of the Jabber Object as a literal COM
object and immutable (interfaces as API).  It might never have dawned on me
that it was actually a python object, and that I could add an attribute at
runtime.  Once my head stopped spinning, it made perfect sense.  Thanks a
bunch!

<snip>
>... In fact, you might
> look at defining custom wxPython command events, and having the Jabber
object
> notify the GUI by posting those events. (This is a somewhat advanced
subject,

I've got some basic functionality to test first, but that is exactly what I
want to try next.

>
> Also, by having both objects holding references to each other, we've
created a
> reference cycle.  Python's garbage collector should be able to handle this
okay,
> but just in case, it's probably a good idea to explicitly destroy the
Jabber
> object in your frame's OnCloseWindow() handler (or whatever name is given
to the
> method that shuts down your frame).  But it's a common idiom in wxPython
for
> parent and child windows to each have references to the other.
(Typically, the
> wxWindows framework will clean up child windows for you, but obviously
wxWindows
> knows nothing of your Jabber object...)
>

Will do.  I appreciate the advice and explanations.  Now, I'm off to make a
bigger mess...

Thanks again,

David
---
--
-






More information about the Python-list mailing list