February 21st, 2005, 01:17 PM
Importing from Distutils
I'm trying to import the file, bConnecter.ocx, which is located in the same directory as my program is. In the code I tried,
But this didn't work. How do I properly import this file?
from distutils.core import bConnecter
February 21st, 2005, 08:13 PM
You can only import Python code modules (*.py), or C/C++ extensions specifically written to be Python modules, e.g. http://docs.python.org/ext/simpleExample.html
In short, you can't.
Unless your ocx is also a COM object,(are they all? I don't know much about them) in which case you can, if you have the win32 extensions installed, but it would be something like:
And wouldn't contain the ocx filename at all.
from win32com.client import Dispatch
myClass = Dispatch("MyApp.SomeClass")
February 22nd, 2005, 12:02 PM
, well that's not good. The reason I needed the OCX was because th VB6 code in it many times couldn't be translated to Python. However, I do have sources of it in C++. So I'm guessing it would work then, with C++?
February 22nd, 2005, 06:00 PM
If the C/C++ files are laid out so that they can be treated as libraries (included by other C/C++ programs) then you may be able to use SWIG to turn them into Python compatible extensions.