[python-win32] COM Base Class and derived classes
tibor.arpas at infinit.sk
Wed Jul 16 15:55:15 CEST 2008
I did use the makepy utility through pythonwin GUI (although I'm not sure It
had any effect)
>>> cs = s.ms.Document.ComponentSet
>>> cs.TypeName # attribute of type Component
>>> cs.Children # attribute of type Folder
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
line 496, in __getattr__
if d is not None: return getattr(d, attr)
line 454, in __getattr__
raise AttributeError, "'%s' object has no attribute '%s'" % (repr(self),
AttributeError: '<win32com.gen_py.Manifold System Type Library.IComponent
instance at 0x39172936>' object has no attribute 'Children'
NOW APPLAYING YOUR ADVICE
>>> f = win32com.client.CastTo(cs,"IFolder")
So yes, I can go this way, although it's much less elegant, then automatic
Thanks a lot,
On Wed, Jul 16, 2008 at 3:07 AM, Mark Hammond <mhammond at skippinet.com.au>
> You probably want to look at using makepy and see if the behaviour
> Note too that the "name" displayed by win32com may not correspond to the
> type of the object at all, particularly when makepy isn't used or for
> whatever reason the object doesn't support type information. Are you
> actually seeing a problem caused by what you describe? If so, what? If the
> problem is that the methods etc from the sub-class aren't seen, then check
> out win32com.client.CastTo()
> *From:* python-win32-bounces at python.org [mailto:
> python-win32-bounces at python.org] *On Behalf Of *Tibor Arpas
> *Sent:* Wednesday, 16 July 2008 12:20 AM
> *To:* python-win32 at python.org
> *Subject:* [python-win32] COM Base Class and derived classes
> I'm new to both python and COM. I try to use the win32com.client. Many
> things work like a charm, but I bumped into following problem. The COM
> server has following hierarchy of types:
> Component (Base class)
> ----- ......
> The components are stored in a collection. When I try to access specific
> component in my script I'm always getting the instance of "Component".
> >>> s.Document.ComponentSet['MyDrawing']
> .... instance of Component ......
> When I try the same thing in IronPython (the COM component has also .NET
> interface and I use the clr library from IronPython), I get the specific
> type. This confirms that at least some of my assumptions are right.
> <DrawingClass object at 0x0000000000000031>
> Can anybody give some pointers where to look and what to check?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the python-win32