summaryrefslogtreecommitdiffstats
path: root/python/examples/example-signal-emitter.py
blob: 662c2bc7478afdca2cd6261d1b6a3ce8322ecb73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python

import dbus
import gtk

class TestObject(dbus.Object):
    def __init__(self, service):
        dbus.Object.__init__(self, "/org/designfu/TestService/object", service)

    @dbus.signal('org.designfu.TestService')
    def HelloSignal(self, message):
        # The signal is emitted when this method exits
	# You can have code here if you wish
        pass

    @dbus.method('org.designfu.TestService')
    def emitHelloSignal(self):
        #you emit signals by calling the signal's skeleton method
	self.HelloSignal("Hello")
	return "Signal emitted"
	
session_bus = dbus.SessionBus()
service = dbus.Service("org.designfu.TestService", bus=session_bus)
object = TestObject(service)

gtk.main()