[pygtk] Drawing widgets in a custom cellrenderer
Johan Dahlin
johan at gnome.org
Fri Dec 7 17:39:51 WST 2007
F Wolff wrote:
> Hi list.
>
> I'm doing a custom cellrenderer similar to this FAQ entry:
> http://faq.pygtk.org/index.py?req=show&file=faq13.045.htp
>
> As part of my rendering I want to display a normal gtk.Widget (a
> container, in my case), but I fail to see how to display it correctly.
> By following the FAQ entry, I get this:
>
> def on_render(self, window, widget, background_area, cell_area, expose_area, flags):
> self.widget.draw(window, widget, cell_area.x, cell_area.y)
> TypeError: GtkWidget.draw() takes exactly 1 argument (4 given)
>
> (by the way, why isn't the gtk.Widget.draw() method documented?)
Because it is deprecated and should not be used.
Use self.widget.window.draw_rectangle() instead.
> I guess another issue is that my self.widget isn't added to some parent
> anywhere, but I don't see where/how it could/should be done (somewhere
> in the treeview?).
I'm not sure what you're trying to do is actually going to work since I
haven't actually tried this myself.
However, if you need to access the parent for whatever reason you need
to add a property just like the FAQ entry 3.45 does, and when you add
the cellrenderer to the treeview column you need to set an extra attribute.
Attributes is a way to map cell renderer properties to a treeview column.
> Can somebody perhaps shed some light on the matter (and perhaps expand
> the FAQ entry if needed)?
Feel free to extend the FAQ, the password is piegtk.
Johan
More information about the pygtk
mailing list