1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
.. wxPython Phoenix documentation
This file was generated by Phoenix's sphinx generator and associated
tools, do not edit by hand.
Copyright: (c) 2011-2020 by Total Control Software
License: wxWindows License
.. include:: headings.inc
.. module:: wx.lib.pubsub.pub
.. currentmodule:: wx.lib.pubsub.pub
.. highlight:: python
.. _wx.lib.pubsub.pub:
==========================================================================================================================================
|phoenix_title| **wx.lib.pubsub.pub**
==========================================================================================================================================
This is the main entry-point to pubsub's core functionality. The :mod:`~pubsub.pub`
module supports:
* messaging: publishing and receiving messages of a given topic
* tracing: tracing pubsub activity in an application
* trapping exceptions: dealing with "badly behaved" listeners (ie that leak exceptions)
* specificatio of topic tree: defining (or just documenting) the topic tree of an
application; message data specification (MDS)
The recommended usage is ::
from pubsub import pub
// use pub functions:
pub.sendMessage(...)
Note that this module creates a "default" instance of
pubsub.core.Publisher and binds several local functions to some of its methods
and those of the pubsub.core.TopicManager instance that it contains. However, an
application may create as many independent instances of Publisher as
required (for instance, one in each thread; with a custom queue to mediate
message transfer between threads).
|function_summary| Functions Summary
====================================
================================================================================ ================================================================================
:func:`~wx.lib.pubsub.pub.getDefaultPublisher` Get the Publisher instance created by default when this module
:func:`~wx.lib.pubsub.pub.getDefaultTopicMgr` Get the TopicManager instance created by default when this
:func:`~wx.lib.pubsub.pub.instantiateAllDefinedTopics` Loop over all topics of given provider and "instantiate" each topic, thus
:func:`~wx.lib.pubsub.pub.isSubscribed` Returns true if listener has subscribed to topicName, false otherwise.
:func:`~wx.lib.pubsub.pub.isValid` Return true only if listener can subscribe to messages of given topic.
:func:`~wx.lib.pubsub.pub.validate` Checks if listener can subscribe to topicName. If not, raises
================================================================================ ================================================================================
|
Functions
------------
.. function:: getDefaultPublisher()
Get the Publisher instance created by default when this module
is imported. See the module doc for details about this instance.
.. function:: getDefaultTopicMgr()
Get the TopicManager instance created by default when this
module is imported. This function is a shortcut for
``pub.getDefaultPublisher().getTopicMgr()``.
.. function:: instantiateAllDefinedTopics(provider)
Loop over all topics of given provider and "instantiate" each topic, thus
forcing a parse of the topics documentation, message data specification (MDS),
comparison with parent MDS, and MDS documentation. Without this function call,
an error among any of those characteristics will manifest only if the a
listener is registered on it.
.. function:: isSubscribed(listener, topicName)
Returns true if listener has subscribed to topicName, false otherwise.
WARNING: a false return is not a guarantee that listener won't get
messages of topicName: it could receive messages of a subtopic of
topicName.
.. function:: isValid(listener, topicName)
Return true only if listener can subscribe to messages of given topic.
.. function:: validate(listener, topicName)
Checks if listener can subscribe to topicName. If not, raises
ListenerMismatchError, otherwise just returns.
|