PyGTK: Manually render an existing widget at a given Rectangle? (TextView in a custom CellRenderer)
Posted
by NicDumZ
on Stack Overflow
See other posts from Stack Overflow
or by NicDumZ
Published on 2010-06-16T09:39:24Z
Indexed on
2010/06/16
9:42 UTC
Read the original article
Hit count: 224
Hello!
I am trying to draw a TextView into the cell of a TreeView. (Why? I would like to have custom tags on text, so they can be clickable and trigger different actions/popup menus depending on where user clicks).
I have been trying to write a customized CellRenderer for this purpose, but so far I failed because I find it extremely difficult to find generic documentation on rendering design in gtk.
More than an answer at the specific question (that might be hard/not doable, and I'm not expecting you to do everything for me), I am first looking for documentation on how a widget is rendered, to understand how one is supposed to implement a CellRenderer. Can you share any link that explains, either for gtk
or for pygtk
, the rendering mechanism? More specifically:
- size allocation mechanism (should I say protocol?). I understand that a window has a defined size, and then queries its children, saying "my size is w x h, what would be your ideal size, buddy?", and then sometimes shrinks children when all children cant fit together at their ideal sizes. Any specific documentation on that, and on particular on when this happens during rendering?
- How are rendered "builtin" widgets? What kind of methods do they call on
Widget
base class? On the parentWindow
? When? Do they usepango.Layout
? - can you manually draw a
TextView
onto apango.Layout
object?
This link gives an interesting example showing how you can draw content in a pango.Layout
object and use it in a CellRenderer
. I guess that I could adapt it if only I understood how TextView
widget are rendered.
Or perhaps, to put it more simply: given an existing widget instance, how does one render it at a specific gdk.Rectangle
?
Thanks a lot.
© Stack Overflow or respective owner