Phoenix Logo

phoenix_title wx.lib.pubsub.utils.notification

Provide an interface class for handling pubsub notification messages, and an example class (though very useful in practice) showing how to use it.

Notification messages are generated by pubsub

  • if a handler has been configured via pub.addNotificationHandler()
  • when pubsub does certain tasks, such as when a listener subscribes to or unsubscribes from a topic

Derive from this class to handle notification events from various parts of pubsub. E.g. when a listener subscribes, unsubscribes, or dies, a notification handler, if you specified one via pub.addNotificationHandler(), is given the relevant information.

copyright:Copyright since 2006 by Oliver Schoenborn, all rights reserved.
license:BSD, see LICENSE_BSD_Simple.txt for details.

function_summary Functions Summary

useNotifyByPubsubMessage Will cause all of pubsub’s notifications of pubsub “actions” (such as
useNotifyByWriteFile Will cause all pubsub notifications of pubsub “actions” (such as

class_summary Classes Summary

IgnoreNotificationsMixin Derive your Notifications handler from this class if your handler
NotifyByPubsubMessage Handle pubsub notification messages by generating
NotifyByWriteFile Print a message to stdout when a notification is received.

Functions



useNotifyByPubsubMessage(publisher=None, all=True, **kwargs)

Will cause all of pubsub’s notifications of pubsub “actions” (such as new topic created, message sent, listener subscribed, etc) to be sent out as messages. Topic will be ‘pubsub’ subtopics, such as ‘pubsub.newTopic’, ‘pubsub.delTopic’, ‘pubsub.sendMessage’, etc.

The ‘all’ and kwargs args are the same as pubsub’s setNotificationFlags(), except that ‘all’ defaults to True.

The publisher is rarely needed:

  • The publisher must be specfied if pubsub is not installed on the system search path (ie from pubsub import ... would fail or import wrong pubsub – such as if pubsub is within wxPython’s wx.lib package). Then pbuModule is the pub module to use:

    from wx.lib.pubsub import pub
    from wx.lib.pubsub.utils import notification
    notification.useNotifyByPubsubMessage()
    


useNotifyByWriteFile(fileObj=None, prefix=None, publisher=None, all=True, **kwargs)

Will cause all pubsub notifications of pubsub “actions” (such as new topic created, message sent, listener died etc) to be written to specified file (or stdout if none given). The fileObj need only provide a ‘write(string)’ method.

The first two arguments are the same as those of NotifyByWriteFile constructor. The ‘all’ and kwargs arguments are those of pubsub’s setNotificationFlags(), except that ‘all’ defaults to True. See useNotifyByPubsubMessage() for an explanation of pubModule (typically only if pubsub inside wxPython’s wx.lib)