msl.loadlib.activex module

Helper module for loading an ActiveX library.

The module also defines all the Window Styles and Extended Window Styles constants.

class msl.loadlib.activex.Forms[source]

Bases: object

Form

alias of object

class msl.loadlib.activex.Application[source]

Bases: object

Create the main application window to display ActiveX controls.

Creating an application requires pythonnet to be installed.

See Form for more details.

Examples

>>> from msl.loadlib.activex import Application
>>> app = Application()
>>> app.create_panel()
<System.Windows.Forms.Panel object at ...>
handle_events(source, sink=None, interface=None)[source]

Handle events from an ActiveX object.

Parameters:
  • source – The ActiveX object that emits events.

  • sink – The object that handles the events. The sink must define methods with the same names as the ActiveX event names. If not specified then uses the calling application instance as the sink.

  • interface – The interface to use.

Returns:

The connection object.

static create_panel()[source]

Create a new Panel.

static load(activex_id, parent=None, x=0, y=0, width=0, height=0, style=0, ex_style=0)[source]

Load an ActiveX library.

Additional information about the keyword arguments are described by the CreateWindowExA object.

Loading an ActiveX library requires comtypes to be installed.

Parameters:
  • activex_id (str) – The ProgID or CLSID of the ActiveX object.

  • parent – The parent or owner window of the window being created. The parent is typically an object from the System.Windows.Forms namespace that has a Handle property.

  • x (int, optional) – The initial horizontal position of the window.

  • y (int, optional) – The initial vertical position of the window.

  • width (int, optional) – The width of the window.

  • height (int, optional) – The height of the window.

  • style (int, optional) – The style of the window being created. This argument can be a combination of the Window Styles constants, e.g., style = WS_CHILD | WS_VISIBLE.

  • ex_style (int, optional) – The extended window style of the window being created. This argument can be a combination of the Extended Window Styles constants, e.g., ex_style = WS_EX_APPWINDOW | WS_EX_CONTEXTHELP.

Returns:

The interface pointer to the ActiveX library.

Raises:

OSError – If the library cannot be loaded.