[pygtk] Subclassing gtk.ToolItem

Douglas S. Blank dblank at cs.brynmawr.edu
Thu Apr 24 20:16:46 WST 2008


> I'm trying to subclass gtk.ToolItem to include a custom widget into it.
>
> Now, when I tried to override the gtk.ToolItem.set_tooltip() method
> python crashes with:
>
> python: Objects/stringobject.c:107: PyString_FromString: Assertion
> `str != ((void *)0)' failed.
>
> Any idea what am I doing wrong?

Hi Zsolt!

Looks like you need to pass in self as the first argument.

-Doug

> Cheers,
> Zsolt
>
> <code>
>
> class ComboToolItem(gtk.ToolItem):
>
>     __gtype_name__ = "ComboToolItem"
>
>     def __init__(self):
>         gtk.ToolItem.__init__(self)
>
>         self.combobox = gtk.combo_box_entry_new_text()
>         self.combobox.show()
>         self.add(self.combobox)
>
>     def do_set_tooltip(self, tooltips, tip_text=None, tip_private=None):
>         gtk.ToolItem.set_tooltip(tooltips, tip_text, tip_private)
>
>         tooltips.set_tip(self.combobox, tip_text, tip_private)
>
> class ComboToolAction(gtk.Action):
>
>     __gtype_name__ = "ComboToolAction"
>
>     def __init__(self, name, label, tooltip, stock_id):
>         gtk.Action.__init__(self, name, label, tooltip, stock_id)
>
> ComboToolAction.set_tool_item_type(ComboToolItem)
>
> </code>
> _______________________________________________
> pygtk mailing list   pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
>



More information about the pygtk mailing list