summaryrefslogtreecommitdiffstats
path: root/python/examples
diff options
context:
space:
mode:
Diffstat (limited to 'python/examples')
-rw-r--r--python/examples/example-client.py9
-rw-r--r--python/examples/example-service.py9
-rw-r--r--python/examples/example-signal-recipient.py4
3 files changed, 19 insertions, 3 deletions
diff --git a/python/examples/example-client.py b/python/examples/example-client.py
index b3b22f56..0270ed6c 100644
--- a/python/examples/example-client.py
+++ b/python/examples/example-client.py
@@ -9,4 +9,13 @@ remote_object = remote_service.get_object("/SomeObject",
hello_reply_list = remote_object.HelloWorld("Hello from example-client.py!")
+hello_reply_tuple = remote_object.GetTuple()
+
+hello_reply_dict = remote_object.GetDict()
+
print (hello_reply_list)
+
+print str(hello_reply_tuple)
+
+print str(hello_reply_dict)
+
diff --git a/python/examples/example-service.py b/python/examples/example-service.py
index 1ea7fd86..e9f407f9 100644
--- a/python/examples/example-service.py
+++ b/python/examples/example-service.py
@@ -5,12 +5,19 @@ import gtk
class SomeObject(dbus.Object):
def __init__(self, service):
- dbus.Object.__init__(self, "/SomeObject", service, [self.HelloWorld])
+ export = [self.HelloWorld, self.GetTuple, self.GetDict]
+ dbus.Object.__init__(self, "/SomeObject", service, export)
def HelloWorld(self, message, hello_message):
print (str(hello_message))
return ["Hello", " from example-service.py"]
+ def GetTuple(self, message):
+ return ("Hello Tuple", " from example-service.py")
+
+ def GetDict(self, message):
+ 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)
diff --git a/python/examples/example-signal-recipient.py b/python/examples/example-signal-recipient.py
index 65e5933a..b5306070 100644
--- a/python/examples/example-signal-recipient.py
+++ b/python/examples/example-signal-recipient.py
@@ -5,9 +5,9 @@ bus = dbus.SessionBus()
service = bus.get_service("org.designfu.TestService")
object = service.get_object("/org/designfu/TestService/object", "org.designfu.TestService")
-def hello_signal_handler(interface, signal_name, service, path, message):
+def hello_signal_handler(sender):
print ("Received signal '%s.%s' from object '%s%s'"
- % (interface, signal_name, service, path))
+ % (sender.interface, sender.signal_name, sender.service, sender.path))
object.connect_to_signal("hello", hello_signal_handler)