summaryrefslogtreecommitdiffstats
path: root/python/examples/example-service.py
blob: 00f39935208ab25d42f1b0c973f13bbaad3a2efa (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
28
29
30
#!/usr/bin/env python

import dbus
import dbus.service
import dbus.glib
import pygtk
import gtk

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

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

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

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

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

gtk.main()