Python Development ActiveX Component Method _python

Source: Internet
Author: User
Use the Win32com module to develop an example of window ActiveX: (If you have not installed the Win32com module, please go to http://python.net/crew/skippy/win32/Downloads.html to download).
Copy 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 to "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 this ActiveX component in an HTML page:
Copy Code code as follows:


Window.onload = function () {
    var obj = new ActiveXObject ("Python.utilities");

    alert (obj. Splitstring ("Hel"));
}
Related Article

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.