4 python example-signal-emitter.py &
5 python example-signal-recipient.py
6 python example-signal-recipient.py --exit-service
13 import dbus
.mainloop
.glib
15 class TestObject(dbus
.service
.Object
):
16 def __init__(self
, conn
, object_path
='/com/example/TestService/object'):
17 dbus
.service
.Object
.__init
__(self
, conn
, object_path
)
19 @dbus.service
.signal('com.example.TestService')
20 def HelloSignal(self
, message
):
21 # The signal is emitted when this method exits
22 # You can have code here if you wish
25 @dbus.service
.method('com.example.TestService')
26 def emitHelloSignal(self
):
27 #you emit signals by calling the signal's skeleton method
28 self
.HelloSignal('Hello')
29 return 'Signal emitted'
31 @dbus.service
.method("com.example.TestService",
32 in_signature
='', out_signature
='')
36 if __name__
== '__main__':
37 dbus
.mainloop
.glib
.DBusGMainLoop(set_as_default
=True)
39 session_bus
= dbus
.SessionBus()
40 name
= dbus
.service
.BusName('com.example.TestService', session_bus
)
41 object = TestObject(session_bus
)
43 loop
= gobject
.MainLoop()
44 print "Running example signal emitter service."