The Python bindings of the MUserEventMessage class also allow communicating with C++ plugins. On the Python side, the client data that is passed to the callbacks is represented as a string containing the binary data (you can use the standard Python module struct to construct or parse such strings). In order to process those strings the size of the binary data has to be known in advance. So before you register a callback you must declare the data size using the setUserEventSize() method (which is specific to the Python bindings). Any client data passed to postEvent() (no matter if the Python version or the C++ version of postEvent() was called) will be wrapped into a Python string of the specified size and passed to the callback. If no client data was specified when calling postEvent() a callback will just receive the client data that has been passed to the addUserEventCallback() method (which may be any Python object).
The following MUserEventMessage methods differ from their C++ counterparts or are specific to the Python bindings:
event, size) |
Note: You must call this function before registering a callback using addUserEventCallback(). The function cannot be used to change the size of any previously registered callback.
event) |
event, clientData=None) |