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

/S

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