On Jul 4, 2007, at 11:20 AM, Simon Dahlbacka wrote:

my best guess is that you should be using .ProductName (capital p) as static dispatch is case sensitive..

/S

Thats not it.

productName is the correct case.

And also..

>>> print c
  <PyIUnknown at 0xac640c with obj at 0xf0d808>
>>> dir(c)
['QueryInterface', '__class__', '__cmp__', '__delattr__', '__doc__', '__getattri bute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__re
pr__', '__setattr__', '__str__']

That doesn't look right at all. Shouldn't I see the COM methods and attributes? For objects that do work I get stuff that looks much more sensible.

>>> print mi
<win32com.gen_py.MIDLibCom 1.0 Type Library.IMIDLib instance at 0x13079016>
>>> dir(mi)
['CLSID', 'CloseCameras', 'OpenCameras', '_ApplyTypes_', '__cmp__', '__doc__', ' __getattr__', '__init__', '__module__', '__repr__', '__setattr__', '_get_good_ob ject_', '_get_good_single_object_', '_oleobj_', '_prop_map_get_', '_prop_map_put
_', 'coclass_clsid']



On 7/4/07, Jason Ferrara < [EMAIL PROTECTED]> wrote:
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






_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32



_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to