summaryrefslogtreecommitdiffstats
path: root/python/examples/example-service.py
blob: 2209ff9f552cda69e35e94640adda247d7d0f096 (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
import dbus

import pygtk
import gtk

class SomeObject(dbus.Object):
    def __init__(self, service):
        dbus.Object.__init__(self, "/SomeObject", service)

    @dbus.method("org.designfu.SampleInterface")
    def HelloWorld(self, hello_message):
        print (str(hello_message))
        return ["Hello", " from example-service.py"]

    @dbus.method("org.designfu.SampleInterface")
    def GetTuple(self):
        return ("Hello Tuple", " from example-service.py")

    @dbus.method("org.designfu.SampleInterface")
    def GetDict(self):
        return {"first": "Hello Dict", "second": " from example-service.py"}

session_bus = dbus.SessionBus()
service = dbus.Service("org.designfu.SampleService", bus=session_bus)
object = SomeObject(service)

gtk.main()