direct.showbase.Messenger
from direct.showbase.Messenger import Messenger
This defines the Messenger class, which is responsible for most of the event handling that happens on the Python side.
Inheritance diagram
- class Messenger[source]
Bases:
object
- __init__(self)[source]
One is keyed off the event name. It has the following structure:
{event1: {object1: [method, extraArgs, persistent], object2: [method, extraArgs, persistent]}, event2: {object1: [method, extraArgs, persistent], object2: [method, extraArgs, persistent]}}
This dictionary allows for efficient callbacks when the messenger hears an event.
A second dictionary remembers which objects are accepting which events. This allows for efficient ignoreAll commands.
Or, for an example with more real data:
{'mouseDown': {avatar: [avatar.jump, [2.0], 1]}}
- accept(self, string, DirectObject, Function, List, Boolean)[source]
Make this object accept this event. When the event is sent (using Messenger.send or from C++), method will be executed, optionally passing in extraArgs.
If the persistent flag is set, it will continue to respond to this event, otherwise it will respond only once.
- find(self, needle)[source]
return a matching event (needle) if found (in haystack). This is primarily a debugging tool.
- findAll(self, needle, limit=None)[source]
return a dict of events (needle) if found (in haystack). limit may be None or an integer (e.g. 1). This is primarily a debugging tool.
- future(self, event)[source]
Returns a future that is triggered by the given event name. This will function only once.
- getAllAccepting(self, object)[source]
Returns the list of all events accepted by the indicated object.
- ignore(self, string, DirectObject)[source]
Make this object no longer respond to this event. It is safe to call even if it was not already accepting
- ignoreAll(self, object)[source]
Make this object no longer respond to any events it was accepting Useful for cleanup
- isIgnoring(self, event, object)[source]
isIgnorning(self, string, DirectObject) Is this object ignoring this event?
- notify = <direct.directnotify.Notifier.Notifier object>
- quiet(self, message)[source]
When verbose mode is on, don’t spam the output with messages marked as quiet. This is primarily a debugging tool.
This is intended for debugging use only. This function is not defined if python is ran with -O (optimize).
See Also:
unquiet
- replaceMethod(self, oldMethod, newFunction)[source]
This is only used by Finder.py - the module that lets you redefine functions with Control-c-Control-v
- send(self, event, sentArgs=[], taskChain=None)[source]
Send this event, optionally passing in arguments.
- Parameters
event (str) – The name of the event.
sentArgs (list) – A list of arguments to be passed along to the handlers listening to this event.
taskChain (str, optional) – If not None, the name of the task chain which should receive the event. If None, then the event is handled immediately. Setting a non-None taskChain will defer the event (possibly till next frame or even later) and create a new, temporary task within the named taskChain, but this is the only way to send an event across threads.
- unquiet(self, message)[source]
Remove a message from the list of messages that are not reported in verbose mode. This is primarily a debugging tool.
This is intended for debugging use only. This function is not defined if python is ran with -O (optimize).
See Also:
quiet
- unwatch(self, needle)[source]
return a matching event (needle) if found (in haystack). This is primarily a debugging tool.
This is intended for debugging use only. This function is not defined if python is ran with -O (optimize).
See Also:
watch