[python-win32] OCX dilemma

Mark Hammond mhammond@skippinet.com.au
Sun, 4 Aug 2002 02:24:37 +1000


> 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 *

This isnt the preferred way of doing this.  Generally you should just run
makepy, and just use win32com.client.Dispatch() with the progID of the
application.  You will find this in any VB/JS samples.

> r=Rtkocr()              # This instantiates a class
> print r

You probably want to instantiate an 'interface'.  The generated code may
well have some comments of the form "this obhect can be created by prog ID
xxx", and these are the objects you want to create, rather than the
"coclass" classes.

If you use the prog ID, it should just work.

> 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)

Well, if you *really* want to continue down this route <wink>,
default_interface is exactly the class you need.
r.default_interface().Init(...) would work, but

In the makepy file the Rtkocr class, another class will be named as the
default_interface.  This is the class name you could instantite instead of
Rtkocr, and it should also work.

Mark.