[pygtk] Subclassing gtk.ToolItem

Steve McClure smcclure at racemi.com
Mon Apr 28 18:57:08 WST 2008


On Apr 28, 2008, at 6:13 AM, zsolt foldvari wrote:

> On 4/24/08, Douglas S. Blank <dblank at cs.brynmawr.edu> wrote:
>>> 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?
>
>> Looks like you need to pass in self as the first argument.
>
> No, it's not the missing self parameter. Any other idea?



>>>    def do_set_tooltip(self, tooltips, tip_text=None,  
>>> tip_private=None):
>>>        gtk.ToolItem.set_tooltip(tooltips, tip_text, tip_private)


I don't see self in the call to ToolItem.set_tooltip.

>
>
> 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/
>>>
>>
>>
> _______________________________________________
> 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/
>

--
Steve McClure
smcclure at racemi.com



More information about the pygtk mailing list