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
http://code.google.com/p/exposong/source/browse/lib/exposong/themeselect.py.
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.
--
Tim Evans
Senior Software Engineer
ARANZ Geo Limited
p: +64 3 374 6120 | e: [email protected]
www.aranzgeo.com
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/