You are not logged in.

#1 2009-08-16 12:59:32

Heller_Barde
Member
Registered: 2008-04-01
Posts: 245

[python/gtk] I need some help with custom cellrenderers in pygtk

Hi everyone

I am in the process of learning and understanding pygtk. While looking at tutorials and documentation, I stumbled upon this strange thing called cellrenderer. Now after some time I understood that it's the V in MVC and that's fine. What I don't get is why there is no CellRendererWidget or in plain English: why can't I easily embed ANY widget inside a ListView Cell?... This seems such a basic and necessary thing.
Oh well, I thought I can write my own CellRenderer for my widget... Now not only doesn't there exist a CellRenderer for widgets, as a bonus they made it extra hard to write your own, because the documentation is very vague IMHO. There seem to  be some methods I would have to create that would be called automagically sometimes
(but god forbid to tell me when and where)

can someone with experience in that field shed some light on that topic?

cheers
Barde

Offline

#2 2009-08-17 16:44:23

tlvb
Member
From: Sweden
Registered: 2008-10-06
Posts: 297
Website

Re: [python/gtk] I need some help with custom cellrenderers in pygtk

There are a lot of different cellrenderer widgets available. Search for 'renderer' here http://www.pygtk.org/docs/pygtk/
EDIT: I have a small piece of code using cellrenderertexsts that I can upload if you need context.
EDIT: For totally custom cellrenderer objects I don't know what to do, but there seem to be some sort of base class that can be used (gtk.GenericCellRenderer).

Last edited by tlvb (2009-08-17 16:48:31)


I need a sorted list of all random numbers, so that I can retrieve a suitable one later with a binary search instead of having to iterate through the generation process every time.

Offline

#3 2009-08-17 22:25:07

Heller_Barde
Member
Registered: 2008-04-01
Posts: 245

Re: [python/gtk] I need some help with custom cellrenderers in pygtk

tlvb wrote:

EDIT: I have a small piece of code using cellrenderertexsts that I can upload if you need context.
EDIT: For totally custom cellrenderer objects I don't know what to do, but there seem to be some sort of base class that can be used (gtk.GenericCellRenderer).

1. I'd like that very much
2. I know, but also there, I find only vague information. I mean, I understand that there is the "render()" method, which seems to be the most important method in this object, but then again, there is an "on_render()" method that I saw in some example iirc and it all made a lot less sense again...

cheers
Barde

Offline

#4 2009-08-17 23:05:44

tlvb
Member
From: Sweden
Registered: 2008-10-06
Posts: 297
Website

Re: [python/gtk] I need some help with custom cellrenderers in pygtk

http://solstorm.doesntexist.com/listexample.py
I haven't worked with other renderers than the one for text though, but I think that if you search in the gtk docs for the C bindings more info should turn up than for python.


I need a sorted list of all random numbers, so that I can retrieve a suitable one later with a binary search instead of having to iterate through the generation process every time.

Offline

Board footer

Powered by FluxBB