Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Python, VB and COM (http://www.velocityreviews.com/forums/t339505-python-vb-and-com.html)

Nick Leaton 12-21-2004 01:15 PM

Python, VB and COM
 
I have a class built as a class library. It makes
a Test.dll, and I can call this from other VB projects

class PyTest

private _name as string

Public Property Name() as string
Get
return _name
End Get
Set (byval value as string)
_name = value
End Set
End Property

End Class

Then I was expecting to do something like

import win32Com.client

pt = win32com.client.Dispatch ("Test.PyTest")
pt.Name = "fred"
print pt.Name

However it doesn't look like the Test.dll is known.
Any pointers?

Thanks

Nick


Steve Holden 12-21-2004 01:53 PM

Re: Python, VB and COM
 
Nick Leaton wrote:

> I have a class built as a class library. It makes
> a Test.dll, and I can call this from other VB projects
>
> class PyTest
>
> private _name as string
>
> Public Property Name() as string
> Get
> return _name
> End Get
> Set (byval value as string)
> _name = value
> End Set
> End Property
>
> End Class
>
> Then I was expecting to do something like
>
> import win32Com.client
>
> pt = win32com.client.Dispatch ("Test.PyTest")
> pt.Name = "fred"
> print pt.Name
>
> However it doesn't look like the Test.dll is known.
> Any pointers?
>
> Thanks
>
> Nick
>

Well, first of all it would have been easier to deal with your specific
problem if you'd copied the error message you got.

Exercising my psychic powers. I'll assume you saw something like

pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)

The best advice I can give is as follows:

1. Start pythonWin
2. Bring up Help | PythonWin Reference
3. Follow the win32com ReadMe link under "Python COM"
4. Follow the "win32com documentation index" link
5. Follow the "A quick start to Client Side COM" link.

The document you reach (yes, accessible, isn't it - I have learned to
accept that in the open source world some people program and some people
write documentation, but the two sets rarely coincide) will explain the
linkages between COM Objects and win32com, and the section under "To
generate Python sources supporting a COM object" is probably what you need.

regards
Steve
--
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/
Holden Web LLC +1 703 861 4237 +1 800 494 3119

Nick 12-21-2004 02:36 PM

Re: Python, VB and COM
 
Thanks Steve.

I eventually found the library. Running makepy over the library
produced the requisite file.

Its working.

Help appreciated.

Nick



All times are GMT. The time now is 01:26 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57