python - using a signal not in introspection

Havoc Pennington hp at redhat.com
Thu Apr 26 09:08:05 PDT 2007


Hi,

John (J5) Palmieri wrote:
> Figured it out.  For some reason the new bindings do not spit out an
> error message when a signal does not match the number of arguments
> listed.  To deal with this you can do
>  
>     def __on_action(self, *args):

Does not work for me with 0.70 anyway. I'll append the test case.

> What is libnotify supposed to be sending back because as far as I can
> tell it does not send back a notify_id though I am guessing it should.
> 

 From what I can tell the args are supposed to be a notify id and an 
action name.

Havoc

#! /usr/bin/python

import dbus, gobject

def callback_noargs():
     print "NO ARGS!"

def callback_args(*args):
     print "ARGS!"

bus = dbus.SessionBus()

o = bus.get_object('org.freedesktop.Notifications', 
'/org/freedesktop/Notifications')
proxy = dbus.Interface(o, 'org.freedesktop.Notifications')

proxy.connect_to_signal('ActionInvoked', callback_args)

bus.add_signal_receiver(callback_args, 'ActionInvoked',
                         named_service='org.freedesktop.Notifications',
                         dbus_interface='org.freedesktop.Notifications',
                         path='/org/freedesktop/Notifications')

proxy.Notify("TestApp",
              0, # "id" - 0 to not replace any existing id
              "", # icon name
              "TITLE",
              "BODY",
              ['mail',
               "OpenMessage",
               'inbox-no-icon',
               "Inbox"],
              {'foo' : 'bar'}, # hints (pydbus barfs if empty)
              10000) # timeout

loop = gobject.MainLoop()
loop.run()



More information about the dbus mailing list