Develop Activex components using Python

Source: Internet
Author: User
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 "));
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.