Example of window ActiveX development using the Win32com module: (If you have not yet installed the Win32com module, please go to http://python.net/crew/skippy/win32/Downloads.html download).
Copy the Code code as follows:
# simplecomserver.py
Class Pythonutilities:
_public_methods_ = [' splitstring ']
_reg_progid_ = "Python.utilities"
_reg_clsid_ = "{a6688635-62f5-41cb-af54-cba84c2f0f86}"
def splitstring (Self, Val):
Return "Hello World", Val
if __name__ = = ' __main__ ':
Print "Registering COM server ..."
Import Win32com.server.register
Win32com.server.register.UseCommandLine (pythonutilities)
Run under console: Python simplecomserver.py
To invoke the ActiveX component in an HTML page:
Copy the Code code as follows:
Window.onload = function () {
var obj = new ActiveXObject ("Python.utilities");
Alert (obj. Splitstring ("Hel"));
}