Python Developing ActiveX Component methods

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

  • 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.