[python-win32] OCX dilemma

Larry Bates lbates@syscononline.com
Fri, 2 Aug 2002 13:42:01 -0500


I'm trying to use Expervision RTKocr toolkit for Optical 
Character Recognition of images.

I have spent the last two days going through documentation, 
old questions posted to this and other lists, you name it.  
I'm attempting to get an OCX to work from within Python.  
So far I have accomplished the following:

1) The OCX is installed on my system and shows up in browser
2) I have run example program that came with toolkit that uses
   the OCX and it works perfectly.
3) I ran makepy and it generated a module that while cryptic,
   appears to work.  At least I can import it without errors.
4) I can create instantiate a class using the class that 
   was defined by makepy, but I can't seem to do anything
   with it.

Example:

I had makepy put it's output for the OCX into rtkocr.py

from rtkocr import *
r=Rtkocr()              # This instantiates a class 
print r

produces:

<win32com.gen_py.rtkocr OLE Control module.Rtkocr>

This looks like its working to me.

Then I get confused

'r' now has 5 methods/attributes CLSID, coclass_interfaces,
coclass_sources, default_interface, default_source.

The one that seems to look promising is default_interface.

r.default_interface shows me the methods that I'm looking
to be able to call.  The first one I need to call is Init

result=r.default_interface.Init(pBasePath,pTempPath,pCustID)

gives the following:

Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
TypeError: unbound method Init() must be called with instance as first argument

Now I'm completely lost.  HELP!  Boy this COM/OCX stuff is REALLY confusing.

Thanks in advance for any assistance.

Regards,
Larry Bates
email: lbates@syscononline.com