开发者

How to Handle Slow Rendering in PyGTK ComboBox

开发者 https://www.devze.com 2023-02-01 00:48 出处:网络
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

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. You can look at it on my Google Code Repository.

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 used a Pixmap that was rendered using idle_add once the screen loaded, since it would not initialize the window until it was rendered inside a window on screen. You can find the code in themeselect.py. Look at load_theme_thumbs(), and _get_pixmap().


I see no harm in rendering it offscreen, as you mentioned, and I've done so for similar reasons. It should be possible unless you're doing something very odd.

0

精彩评论

暂无评论...
验证码 换一张
取 消