summaryrefslogtreecommitdiffstats
path: root/python/examples/example-signal-emitter.py
blob: f81ac3fb4cc7cf30cd3820258da967cd4feaf604 (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
27
#!/usr/bin/env python

import dbus
import dbus.service
import gtk

class TestObject(dbus.service.Object):
    def __init__(self, bus_name, object_path='/org/designfu/TestService/object'):
        dbus.service.Object.__init__(self, bus_name, object_path)

    @dbus.service.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.service.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()
name = dbus.service.BusName('org.designfu.TestService', bus=session_bus)
object = TestObject(name)

gtk.main()