[pygtk] custom CellRenderer and custom signals - how?

Don Question donquestion at rocketmail.com
Thu Mar 4 00:14:26 WST 2010


Hi pygtk-wizards,

if i were to make a custom cellrenderer class derived from e.g. CellRendererPixbuf
i would suppose to start like this:

class CellRendererPixbufXt(gtk.CellRendererPixbuf):
    """docstring for CellRendererPixbufXt"""
    __gproperties__ = { 'active-state' :
                        (gobject.TYPE_STRING, 'pixmap/active widget state',
                        'stock-icon name representing active widget state',
                        None, gobject.PARAM_READWRITE) }
    __gsignals__    = { 'clicked' :
                        (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()) , }
    states = [ None, gtk.STOCK_APPLY, gtk.STOCK_CANCEL ]

    def __init__( self ):
        gtk.CellRendererPixbuf.__init__( self )

    def do_get_property( self, property ):
        """docstring for do_get_property"""
        if property.name == 'active-state':
            return self.active_state
        else:
            raise AttributeError, 'unknown property %s' % property.name

    def do_set_property( self, property, value ):
        if property.name == 'active-state':
            self.active_state = value
        else: 
            raise AttributeError, 'unknown property %s' % property.name
 
but i'm not sure how to emit the custom "clicked" signal, when the user clicks
on the CellRenderer. Because the cellrenderer doesn't inherit from the gtk.Widget i can't
use the event-signals to bypass this problem.

Maybe you know a solution, or the "proper" way to do this.

Thanks in advance
Don



      



More information about the pygtk mailing list