[python-win32] issues with win32com constants and static/dynamic dispatch
Jason Ferrara
jason.ferrara at jacquette.com
Wed Jul 4 16:30:26 CEST 2007
I'm trying to use a COM library from python.
If I use dynamic dispatch, the com objects all behave correctly, but
the constants defined in the COM library don't show up.
If I use static dispatch, the constants show up, but COM objects
returned by calls into the COM library seem broken.
As example, starting with dynamic dispatch
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32
bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more
information.
>>> import win32com.client
>>> mi=win32com.client.Dispatch("MIDLIBCom.MIDLib")
>>> cams=mi.OpenCameras("C:\Program Files\Micron Imaging
\sensor_data")
>>> c=cams[0]
>>> print c
<COMObject OpenCameras>
>>> print c.productName
Micron Imaging DEMO2
So far everything is fine, but now...
>>> print win32com.client.constants.MI_BAYER_8
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python25\Lib\site-packages\win32com\client
\__init__.py", line 168, in
__getattr__
raise AttributeError, a
AttributeError: MI_BAYER_8
This is no good. So now I try static dispatch
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32
bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more
information.
>>> import win32com.client
>>> mi=win32com.client.gencache.EnsureDispatch("MIDLIBCom.MIDLib")
>>> print win32com.client.constants.MI_BAYER_8
1
Things are looking better, but now...
>>> cams=mi.OpenCameras("C:\Program Files\Micron Imaging
\sensor_data")
>>> c=cams[0]
>>> print c
<PyIUnknown at 0xac640c with obj at 0xf0d808>
>>> print c.productName
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'PyIUnknown' object has no attribute 'productName'
So whats going on here? What am I doing wrong?
Thanks
- J
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20070704/c57e0eb9/attachment.html
More information about the Python-win32
mailing list