Results 1 to 2 of 2

Thread: PyGTK custom signals send a list as parameter

  1. #1
    Join Date
    Sep 2013
    Beans
    3

    PyGTK custom signals send a list as parameter

    I'm trying to add a custom signal to a class -

    Code:
    class TaskBrowser(gobject.GObject):
        __list_signal__ = (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (<List datatype>,))
        __gsignals__ = {'tasks-deleted': __list_signal__}
    
        ...
    
        def on_delete_tasks(self, widget=None, tid=None):
            ...
            gobject.idle_add(self.emit, "tasks-deleted", deleted_tasks) #deleted_tasks is of type 'list'
            ...
    
        ...
    In the __gsignals__ dict, when I state list as parameter type, I get the following error traceback -

    Code:
    File "/home/manhattan/GTG/Hamster_in_hands/GTG/gtk/browser/browser.py", line 61, in <module>
      class TaskBrowser(gobject.GObject):
    File "/usr/lib/python2.7/site-packages/gobject/__init__.py", line 60, in __init__
      cls._type_register(cls.__dict__)
    File "/usr/lib/python2.7/site-packages/gobject/__init__.py", line 115, in _type_register
      type_register(cls, namespace.get('__gtype_name__'))
    TypeError: Error when calling the metaclass bases
      could not get typecode from object​

    I saw the list of possible parameter types, and there's no type for list

    Is there a way I can pass a list as a signal parameter ?

  2. #2
    Join Date
    Nov 2009
    Beans
    49

    Re: PyGTK custom signals send a list as parameter

    Code:
    __list_signal__ = (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,))
    You use gobject.TYPE_PYOBJECT. Look into how python communicates with C code and vice versa and you'll understand more about what exactly is going on.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •