Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Calling a Python COM object from MATLAB
Date: Thu, 18 Jun 2009 22:00:04 +0000 (UTC)
Organization: Georgia Institute of Technology
Lines: 39
Message-ID: <h1edd4$ngr$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1245362404 24091 172.30.248.37 (18 Jun 2009 22:00:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 18 Jun 2009 22:00:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1344740
Xref: news.mathworks.com comp.soft-sys.matlab:548777


Okay, so I need to call a Python COM object from MATLAB. I can do it from Excel just fine, but when I use ACTXSERVER it seems to load it but when queried for methods and other things it just seems to be empty.

In MATLAB I type the call below to get a handle h to the Python object (the Python code is at the end of the post)

>> h = actxserver('python.try2')
 
h =
 
	COM.python_try2

when I use the methods function to see what methods the object has, I only get the MATLAB ones:

>> methods(h)

Methods for class COM.python_try2:

addproperty      deleteproperty   interfaces       move             save             
constructorargs  events           invoke           propedit         send             
delete           get              load             release          set    


This is the Python test code:

class PythonUtilities:
    _public_methods_ = ['hello']
    _reg_progid_ = "Python.Try2"
    _reg_clsid_ = "{19353e9b-964a-4b1c-8cd1-baccc0209af3}"
    
    def hello(self, string):
        return string

if __name__=='__main__':
    print "Registering COM server..."
    import win32com.server.register
    win32com.server.register.UseCommandLine(PythonUtilities)

Any ideas are welcome, at the very least, thanks for reading this post.

-Santiago