[python-win32] OCX dilemma

Jim Vickroy Jim.Vickroy@noaa.gov
Fri, 02 Aug 2002 13:37:03 -0600


Hello Larry,


I have no familiarity with this application, but in case no one more knowledgeable
answers I can at least try to interpret the error message ...

TypeError: unbound method Init() must be called with instance as first argument

indicates, to me, that you must first construct/initialize an **instance** of the
class whose Init() procedure you are trying to apply.  For example:

> my_instance = r.default_interface.<__init__procedure_name_goes_here()>
> my_instance.Init(...)

Hope this helps -- good luck.


Larry Bates wrote:

> 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
>
> _______________________________________________
> Python-win32 mailing list
> Python-win32@python.org
> http://mail.python.org/mailman/listinfo/python-win32