Exemple #1
0
class TestSignal(signals.Provider):
    def __init__(self):
        signals.Provider.__init__(self)
        self.signal_new("test-signal")


test = TestSignal()


def timer_cb(a):
    print "timer argument", a
    signals.emit("test-signal")
    test.signal_emit("test-signal")
    print "-------------------------"
    return True


def signal_cb(signal, a, b):
    print "signal arguments", signal, a, b
    signals.disconnect("test-signal", signal_cb)


notifier.init(notifier.GENERIC)

signals.new("test-signal")
signals.connect("test-signal", notifier.Callback(signal_cb, 1, 2, "global signal"))
test.signal_connect("test-signal", notifier.Callback(signal_cb, 1, 2, "TestSignal signal"))
notifier.timer_add(2000, notifier.Callback(timer_cb, 7))

notifier.loop()
Exemple #2
0
import notifier
import notifier.signals as signals

class TestSignal( signals.Provider ):
	def __init__( self ):
		signals.Provider.__init__( self )
		self.signal_new( 'test-signal' )

test = TestSignal()

def timer_cb( a ):
	print 'timer argument', a
	signals.emit( 'test-signal' )
	test.signal_emit( 'test-signal' )
	print '-------------------------'
	return True

def signal_cb( signal, a, b ):
	print 'signal arguments', signal, a, b
	# disconnect global signal
	signals.disconnect( 'test-signal', signal_cb )

notifier.init( notifier.GENERIC )

signals.new( 'test-signal' )
signals.connect( 'test-signal', notifier.Callback( signal_cb, 1, 2, 'global signal' ) )
test.signal_connect( 'test-signal',notifier.Callback( signal_cb, 1, 2, 'TestSignal signal' ) )
notifier.timer_add( 2000, notifier.Callback( timer_cb, 7 ) )

notifier.loop()
Exemple #3
0
        self.signal_new('test-signal')


test = TestSignal()


def timer_cb(a):
    print 'timer argument', a
    signals.emit('test-signal')
    test.signal_emit('test-signal')
    print '-------------------------'
    return True


def signal_cb(signal, a, b):
    print 'signal arguments', signal, a, b
    # disconnect global signal
    signals.disconnect('test-signal', signal_cb)


notifier.init(notifier.GENERIC)

signals.new('test-signal')
signals.connect('test-signal',
                notifier.Callback(signal_cb, 1, 2, 'global signal'))
test.signal_connect('test-signal',
                    notifier.Callback(signal_cb, 1, 2, 'TestSignal signal'))
notifier.timer_add(2000, notifier.Callback(timer_cb, 7))

notifier.loop()
Exemple #4
0
import notifier
import notifier.signals as signals

def _wait_for_click():
	print "clicked"

def _wait_for_movement( optional = None ):
	print "optional:", optional

def _emitting():
	signals.emit( "clicked" )
	# return True

if __name__ == '__main__':
	notifier.init( notifier.GENERIC )

	signals.new( "clicked" )
	try:
		signals.connect( "clicked2", _wait_for_click )
	except signals.UnknownSignalError, e:
		print 'Exception:', e
	if not signals.exists( 'clicked3' ):
		print "signal 'clicked3' does not exist"
	signals.connect( 'clicked', _wait_for_click )
	signals.connect( 'clicked', notifier.Callback( _wait_for_movement,
												 'optional something' ) )
	notifier.timer_add( 3000, _emitting )

	notifier.loop()