mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2025-12-25 19:50:08 +01:00
* python/service.py (class Name): renamed BusName to make it clearer what the object is for (a name on the bus) * python/examples/example-service.py, python/examples/example-signal-emitter.py: change the Name object to BusName
30 lines
862 B
Python
30 lines
862 B
Python
#!/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()
|