I got it!<br>I use the wrong object path, so i can't get the signal<br>the correct one is /org/freedesktop/DBus,as follows<br>proxy = sessionBus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus')<br>
<br>Thank you!<br><br><br><br>_______________________________<br>quoted text:<br><br>Thanks.Maybe i don't totally get what you mean.<br>i tried the following code.When rhythmbox lauches or quits,nothing is printed.<br>
Code in python:<br><br>import dbus<br>from dbus.mainloop.glib import DBusGMainLoop<br>
import gobject<br>import glib<br><br>class Test:<br> def __init__(self):<br> DBusGMainLoop(set_as_default=<div id=":8i" class="ii gt">True)<br> sessionBus = dbus.SessionBus()<br><br> proxy = sessionBus.get_object('org.freedesktop.DBus', '/')#this object path is wrong<br>
self.interface = dbus.Interface(proxy, 'org.freedesktop.DBus')<br> self.interface.connect_to_signal('NameOwnerChanged', self.callback)<br><br> gobject.MainLoop().run()<br>
<br> def callback(self, s1, s2, s3):<br> print s1, s2, s3<br><br>if __name__ == '__main__':<br> Test()</div><br>