win32com: subclass a com object?
tiddlerdeja at my-deja.com
tiddlerdeja at my-deja.com
Sun Dec 12 18:43:58 EST 1999
In article <slrn857udf.dqp.bernhard at alpha1.csd.uwm.edu>,
bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) wrote:
> On Sun, 12 Dec 1999 18:29:31 GMT, tiddlerdeja at my-deja.com
<tiddlerdeja at my-deja.com> wrote:
>
> >I'd like to know how to subclass or derive from a existing COM
object.
> >This subclass would implemented as a COM object itself. The "create a
> >COM object in python" I can do. It's just the inheritance I can't.
I'd
> >like then to override a method of the base class in the derived
class.
> >(I have run makepy.py over the existing/base COM object already).
>
> Hmm. I haven't done this, but you certainly can derive from the
> class, which wraps the COM object and intercept the method.
>
> Mark can tell you more about it.
> The most easiest solution would be to write your own class,
> initialise instances with the original COM instance
> and just imitate all methods and call the original object except of
> course for the method you want to change.
>
>
I know I'm being pretty lame, but could you give me an example? Even for
say MS Word?
I know about python inheritance (I should have made this clear in the
original message).
Perhaps my lack of understanding is the COM/python integration. With COM
you use the Dispatch method to create an instance. If you create a
python subclass, e.g.:
class myMSWord(MSWord):
...
Eh, how do you create a myMSWord? or where does the Dispatch call come
into it?
Or, after you run makepy.py over MSWord, which creates a file
xyz-123-abc.py under gen_py, how do you import it and which class do you
derive from?
Or maybe I don't know about python inheritance after all! :)
Any help appreciated.
Kieran
>
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list