The powerful function of Python lies in its omnipotent power. Example of window ActiveX Development using the win32com module: (If you have not installed the win32com module, download it at http://python.net/crew/skippy/win32/downloads.html ).
The code is 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 python SimpleCOMServer. py on the console.
Call the Activex component on the HTML page:
The code is as follows:
Window. onload = function (){
Var obj = new ActiveXObject ("Python. Utilities ");
Alert (obj. SplitString ("El "));
}