コード例 #1
0
def threadObserver(transfers, threadObj, count):
    """Listener that listens for data from testTopic. This function
    doesn't know where the data comes from (or in what thread it was
    generated... but threadObj is the thread in which this
    threadObserver is called and should indicate Main thread)."""

    print_(transfers, threadObj, count / resultStep)
コード例 #2
0
    def run(self):
        print_('aux thread started')
        self.running = True
        while self.running:
            self.count += 1
            if self.count % resultStep == 0:
                self.queue.put(self.count)

        print_('aux thread done')
コード例 #3
0
ファイル: main.py プロジェクト: flg8r96/eventprocessor
def main():
    # do stuff

    # creating manual state changes
    #a = exithouse.ExitHouse(initdict)
    #initdict["dooropen_flag"] = True
    #ruleoutcome = a.evaluateRule(**initdict)
    #print "Main: outcome of ExitHouse:EvaluateRule: " + str(ruleoutcome)

    # creating windows that help create automatic state changes
    app = wx.App()
    c = Controller()
    sys.stdout = sys.__stdout__

    print_('---- Starting main event loop ----')
    app.MainLoop()
    print_('---- Exited main event loop ----')
コード例 #4
0
def main():
    idleFns = [] # list of functions to call when 'gui' idle
    idleFns.append( onIdle )

    try:
        thread.start()

        print_('starting event loop')
        eventLoop = True
        while eventLoop:
            time.sleep(1) # pretend that main thread does other stuff
            for idleFn in idleFns:
                idleFn()

    except KeyboardInterrupt:
        print_('Main interrupted, stopping aux thread')
        thread.stop()

    except Exception as exc:
        from pubsub import py2and3
        exc = py2and3.getexcobj()
        print_(exc)
        print_('Exception, stopping aux thread')
        thread.stop()
コード例 #5
0
ファイル: multithreadloop.py プロジェクト: wangdyna/wxPython
def main():
    idleFns = []  # list of functions to call when 'gui' idle
    idleFns.append(onIdle)

    try:
        thread.start()

        print_('starting event loop')
        eventLoop = True
        while eventLoop:
            time.sleep(1)  # pretend that main thread does other stuff
            for idleFn in idleFns:
                idleFn()

    except KeyboardInterrupt:
        print_('Main interrupted, stopping aux thread')
        thread.stop()

    except Exception as exc:
        from pubsub import py2and3
        exc = py2and3.getexcobj()
        print_(exc)
        print_('Exception, stopping aux thread')
        thread.stop()
コード例 #6
0
def doSomething2():
    print_('--- SENDING topic1 message ---')
    pub.sendMessage('topic1', msg='message for 1')
    print_('---- SENT topic1 message ----')
コード例 #7
0
ファイル: exchandle.py プロジェクト: 2015E8007361074/wxPython
 def __call__(self, listenerID):
     print_('Exception raised in listener %s during sendMessage()' % listenerID)
     print_(TracebackInfo())
コード例 #8
0
def listenerFn(msg, msg2, extra=None):
    print_('Function listenerFn received: ', repr(msg), repr(msg2), repr(extra))
コード例 #9
0
 def onRemove(self, evt):
     print_('-----')
     pub.sendMessage("money_changing", amount=-self.CHANGE)
コード例 #10
0
 def __call__(self, msg):
     print_('Listener instance received: ', msg.data)
コード例 #11
0
 def onTopic1(self, msg, topic=pub.AUTO_TOPIC):
     msg = msg.data[0]
     info = 'Method Listener.onTopic1 received "%s" message: %s'
     print_(info % (topic.getName(), repr(msg)))
コード例 #12
0
 def onTopic2(self, data, topic=pub.AUTO_TOPIC):
     info = 'Method Listener.onTopic2 received "%s" message: %s'
     print_(info % (topic.getName(), repr(data.data1)))
コード例 #13
0
 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()))
コード例 #14
0
 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()))
コード例 #15
0
ファイル: wx_win2.py プロジェクト: flg8r96/pytesting
 def onStop(self, evt):
     print_('----- Timer Stoping PUB')
     pub.sendMessage("timer_stopping", amount = 0)
コード例 #16
0
ファイル: wx_win2.py プロジェクト: flg8r96/pytesting
 def onStart(self, evt):
     print_('----- Timer Starting PUB')
     pub.sendMessage("timer_starting", amount = self.initialValue)
コード例 #17
0
ファイル: wx_win2.py プロジェクト: flg8r96/pytesting
 def onStop(self, evt):
     print_('----- Timer Stoping PUB')
     pub.sendMessage("timer_stopping", amount=0)
コード例 #18
0
ファイル: wx_win2.py プロジェクト: flg8r96/pytesting
 def onStart(self, evt):
     print_('----- Timer Starting PUB')
     pub.sendMessage("timer_starting", amount=self.initialValue)
コード例 #19
0
 def onTopic11(self, msg):
     data = msg.data
     print_('Method Listener.onTopic11 received: ', `data`)
コード例 #20
0
def listenerFn(msg):
    data = msg.data
    print_('Function listenerFn received: ', `data`)
コード例 #21
0
 def onTopic_2(self, arg1, topic=pub.AUTO_TOPIC):
     info = 'Method Listener.onTopic_2 received "%s" message: %s'
     print_(info % (topic.getName(), arg1))
コード例 #22
0
def listenerFn(msg):
    msg, extra = msg.data
    print_('Function listenerFn received: ', repr(msg), repr(extra))
コード例 #23
0
def listenerFn(msg):
    data = msg.data
    print_('Function listenerFn received: ', repr(data))
コード例 #24
0
def listenerFn(msg, extra=None):
    print_('Function listenerFn received: ', repr(msg), repr(extra))
コード例 #25
0
def doSomething1():
    print_('--- SENDING topic1.subtopic11 message ---')
    pub.sendMessage('topic1.subtopic11', ('message for 11', 123))
    print_('---- SENT topic1.subtopic11 message ----')
コード例 #26
0
def doSomething1():
    print_('--- SENDING topic1.subtopic11 message ---')
    pub.sendMessage('topic1.subtopic11', msg='message for 11', extra=123)
    print_('---- SENT topic1.subtopic11 message ----')
コード例 #27
0
 def onTopic11(self, msg, msg2, extra=None):
     print_('Method Listener.onTopic11 received: ', repr(msg), repr(msg2), repr(extra))
コード例 #28
0
def doSomething1():
    print_('--- SENDING topic1.subtopic11 message ---')
    pub.sendMessage('topic1.subtopic11', ('message for 11', 123))
    print_('---- SENT topic1.subtopic11 message ----')
コード例 #29
0
ファイル: main.py プロジェクト: flg8r96/eventprocessor
__author__ = 'matt'


import pubsub
import exithouse
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_statuswin import View
from wx_controlwin import ChangerWidget



class Model:

  def __init__(self):
    print "Main:Model:initializing local variables ... "
    self.inhousestate = True
    self.motionin_flag = True
    self.motionout_flag = True
    self.dooropen_flag = False
コード例 #30
0
def doSomething2():
    print_('--- SENDING topic1 message ---')
    pub.sendMessage('topic1', ('message for 1',) )
    print_('---- SENT topic1 message ----')
コード例 #31
0
def run():
    print_('Using "kwargs" messaging protocol of pubsub v3')

    senders.doSomething1()
    senders.doSomething2()
コード例 #32
0
 def __call__(self, **kwargs):
     print_('Listener instance received: ', kwargs)
コード例 #33
0
 def __call__(self, listenerID):
     print_('Exception raised in listener %s during sendMessage()' %
            listenerID)
     print_(TracebackInfo())
コード例 #34
0
ファイル: main_arg1.py プロジェクト: 2015E8007361074/wxPython
:copyright: Copyright since 2006 by Oliver Schoenborn, all rights reserved.
:license: BSD, see LICENSE.txt for details.
"""

from pubsub import setuparg1
from pubsub import pub
from pubsub.py2and3 import print_

import notifhandle
import exchandle

import arg1_topics

#***** actual application **********

print_('Using "arg1" messaging protocol of pubsub v3')

try:
    print_('------- init ----------')

    pub.addTopicDefnProvider( arg1_topics, pub.TOPIC_TREE_FROM_CLASS )
    pub.setTopicUnspecifiedFatal()

    import arg1_listeners
    import arg1_senders as senders

    print_('-----------------------')
    senders.doSomething1()
    senders.doSomething2()

    print_('------- done ----------')
コード例 #35
0
ファイル: main_arg1.py プロジェクト: wangdyna/wxPython
:copyright: Copyright since 2006 by Oliver Schoenborn, all rights reserved.
:license: BSD, see LICENSE.txt for details.
"""

from pubsub import setuparg1
from pubsub import pub
from pubsub.py2and3 import print_

import notifhandle
import exchandle

import arg1_topics

#***** actual application **********

print_('Using "arg1" messaging protocol of pubsub v3')

try:
    print_('------- init ----------')

    pub.addTopicDefnProvider(arg1_topics, pub.TOPIC_TREE_FROM_CLASS)
    pub.setTopicUnspecifiedFatal()

    import arg1_listeners
    import arg1_senders as senders

    print_('-----------------------')
    senders.doSomething1()
    senders.doSomething2()

    print_('------- done ----------')
コード例 #36
0
def doSomething1():
    print_('--- SENDING topic1.subtopic11 message ---')
    pub.sendMessage('topic1.subtopic11', msg='message for 11', extra=123)
    pub.sendMessage('subtopic11', msg='message for 11', extra=123)
    print_('---- SENT topic1.subtopic11 message ----')
コード例 #37
0
ファイル: wx_win2.py プロジェクト: 2015E8007361074/wxPython
 def onRemove(self, evt):
     print_('-----')
     pub.sendMessage("money_changing", amount = - self.CHANGE)
コード例 #38
0
def doSomething4():
    print_('--- SENDING topic_2 message ---')
    pub.sendMessage('topic_2.subtopic_21', arg1="Test")
    print_('---- SENT topic_2 message ----')
コード例 #39
0
__author__ = 'matt'

import pubsub
import exithouse
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_statuswin import View
from wx_controlwin import ChangerWidget


class Model:
    def __init__(self):
        print "Main:Model:initializing local variables ... "
        self.inhousestate = True
        self.motionin_flag = True
        self.motionout_flag = True
        self.dooropen_flag = False
        self.motionouttimer_flag = False
        self.initdict = {
コード例 #40
0
 def __call__(self, msg):
     print_('Listener instance received: ', msg.data)
コード例 #41
0
def run():
    print_('Using "arg1" messaging protocol of pubsub v3')

    senders.doSomething1()
    senders.doSomething2()
コード例 #42
0
 def onTopic11(self, msg):
     msg, extra = msg.data
     print_('Method Listener.onTopic11 received: ', repr(msg), repr(extra))
コード例 #43
0
 def onTopic11(self, msg, extra=None):
     print_('Method Listener.onTopic11 received: ', repr(msg), repr(extra))
コード例 #44
0
 def __call__(self, msg):
     print_('Listener instance received: ', repr(msg))
コード例 #45
0
 def __call__(self, **kwargs):
     print_('Listener instance received: ', kwargs)
コード例 #46
0
"""
Adapted from wxPython website at http://wiki.wxpython.org/ModelViewController/.

: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):
コード例 #47
0
 def onTopic11(self, msg):
     data = msg.data
     print_('Method Listener.onTopic11 received: ', repr(data))