[pygtk] ComboBox Unresponsive with Custom CellRenderer
t.evans at aranz.com
Tue Dec 28 08:42:11 WST 2010
On 2010-12-23 06:35, Bradlee Landis wrote:
> I have implemented a custom CellRenderer in PyGTK that can take longer
> to render than is ideal. There can be multiple images that have to be
> scaled, so when the user clicks on the ComboBox, it won't even show
> the popup until the rendering is completed. If I can show the popup,
> and then render the image, that would be fine. My code is currently at
> I have implemented caching, so that after it loads the first time, it
> will load from a single image from memory or disk, but the first time
> it loads can take 2-4 seconds per cell.
> The things that I have thought of implementing, include, pop up the
> combobox when the application loads, so that it forces it to render
> the image. This does not seem to be working in the tests I have run.
> I have also tried to create a CairoContext and surface that is not
> visible, but I require it to be a gtk.gdk.CairoContext, which I don't
> think can be initiated without an actual widget. There's a possibility
> that I could render this in a widget offscreen, but I'm not sure if
> that's a good idea, or even possible.
> I hope I can get more support than I have in the past.
The way I would probably implement this would be the cache the theme
thumbnails into pixbufs and use a plain gtk.CellRendererPixbuf.
I would create the thumbnails in a background thread on program start,
or possibly as needed if I was feeling ambitious. If they're not done by
the time the UI needs to render one you could either just block until
they're done if that won't take long, or show a blank image and replace
it once the thumbnail is done.
The implementation details are likely to be complex, as is always the
case when threads are involved.
Senior Software Engineer
ARANZ Geo Limited
p: +64 3 374 6120 | e: t.evans at aranz.com
More information about the pygtk