Ejemplo n.º 1
0
def testNotifications():
    capture = io.StringIO()
    logger = notification.useNotifyByWriteFile(capture)
    from pubsub import pub
    def block():
        def listener(): pass
        pub.subscribe(listener, 'testNotifications')
    block()
Ejemplo n.º 2
0
def testNotifications():
    capture = io.StringIO()
    logger = notification.useNotifyByWriteFile(capture)
    from pubsub import pub

    def block():
        def listener():
            pass

        pub.subscribe(listener, 'testNotifications')

    block()
Ejemplo n.º 3
0
:copyright: Copyright since 2006 by Oliver Schoenborn, all rights reserved.
:license: BSD, see LICENSE.txt for details.
"""

import wx

from pubsub import pub
from pubsub.py2and3 import print_

print_('pubsub API version', pub.VERSION_API)

# notification
from pubsub.utils.notification import useNotifyByWriteFile
import sys
useNotifyByWriteFile(sys.stdout)

# the following two modules don't know about each other yet will
# exchange data via pubsub:
from wx_win1 import View
from wx_win2 import ChangerWidget


class Model:

  def __init__(self):
    self.myMoney = 0

  def addMoney(self, value):
    self.myMoney += value
    #now tell anyone who cares that the value has been changed
Ejemplo n.º 4
0
"""

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

"""

import sys

from pubsub import pub
from pubsub.utils.notification import useNotifyByWriteFile, IgnoreNotificationsMixin


# create one special notification handler that ignores all except
# one type of notification
class MyPubsubNotifHandler(IgnoreNotificationsMixin):
    def notifySubscribe(self, pubListener, topicObj, newSub):
        newSubMsg = ''
        if not newSub:
            newSubMsg = ' was already'
        msg = 'MyPubsubNotifHandler: listener %s%s subscribed to %s'
        print(msg % (pubListener.name(), newSubMsg, topicObj.getName()))


pub.addNotificationHandler(MyPubsubNotifHandler())

# print(all notifications to stdout)

useNotifyByWriteFile(sys.stdout, prefix='NotifyByWriteFile:')
Ejemplo n.º 5
0
def captureStdout():
    capture = io.StringIO()
    useNotifyByWriteFile( fileObj = capture )
    return capture
Ejemplo n.º 6
0
def captureStdout():
    capture = io.StringIO()
    useNotifyByWriteFile(fileObj=capture)
    return capture