#1
  1. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154

    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,
    Code:
    from distutils.core import bConnecter
    But this didn't work. How do I properly import this file?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Posts
    624
    Rep Power
    34
    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:

    Code:
    from win32com.client import Dispatch
    myClass = Dispatch("MyApp.SomeClass")
    And wouldn't contain the ocx filename at all.
  4. #3
  5. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    , 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++?
  6. #4
  7. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    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.

    http://www.swig.org/

    Take care,

    Mark.
    programming language development: www.netytan.com Hula


IMN logo majestic logo threadwatch logo seochat tools logo