he facilities for the event trapping are provided by the predefined object
ExcelListener. Each of the On<Event> properties has the methods "bind"
and "bindTo" for assigning a callable object intended to be called if the
event is fired. The method "signature" returns a description of the signature
that the callable object is expected to have.
The method "bind" assigns a general handler to be run every time when an event
of the particular type is fired.
The method "bindTo" provides selective handler assignment. Its first argument
takes either string, unicode or a PFE object. Such argument selects the source
of the event to be bound to the event handler. When an event is fired the
ExcelListener would obtain the source of event (workbook or worksheet). Such
source always has a name. The ExcelListener would run all handlers assigned to
the event by "bind". It would also run only those handlers assigned by
"bindTo" to an object of the same name.
The methods "unbind" and "unbindTo" remove the event handlers.
The intended place of use for the ExcelListener is a pfe-script. See the
section on configuration files for information on pfe-scripts. The
ExcelListener may also be used in the ControlShell.
IMPORTANT!!!! The ExcelListener does not do any exception catching for the
event handlers. It executes the handlers one-by-one and allows an exception to
propagate if thrown. The user may replace this behavior by modifying the
Python implementation of the ExcelListener in the file vbaEvents.py located in
the PythonForExcel installation directory. The exact place for such
modification if the __call__ method of the _Binder class. This method is also
the place where the programmer may study and/or modify the order of execution
for the event handlers.
IMPORTANT!!!! The "OnWorkbookOpen" handlers should not contain calls to
"Activate" method.
|