View Single Post
Old 12-15-2010, 12:17 PM   #18
chaley
Wizard
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 3,853
Karma: 285886
Join Date: Jan 2010
Location: France
Device: Sony PRS-300, HTC WM6.5, Samsung Galaxy Nexus, HTC Sensation
Quote:
Originally Posted by kiwidude View Post
Code:
                        actual_icon = None
                        try:
                            resource = self.load_resource(icon_name)
                            pixmap = QPixmap()
                            pixmap.loadFromData(resource)
                            actual_icon = QIcon(pixmap)
                        except ValueError:
                            actual_icon = QIcon(I(icon_name))
                        ac.setIcon(actual_icon)
Given the new list interface, the problem becomes much more tractable. You load the icons you need from the zip into the dict. Some might not be there. You then loop through the items you need using a simple if x in list: test. If they is in the dict, cool. If not, you use the file approach. That lets the customizers put their icons in the local resources/images directory (or a subdir if they want to). There is almost zero time penalty because the zip scan was done once and you would need to open the files anyway.
Quote:
And yeah as Chaley says if you have a lot of icons you are opening/closing the zip a lot of times.
Problem gone with list interface.
__________________
Support calibre developers at no cost to you by using calibre's get books feature.
Use Calibre Companion to wirelessly connect your Android phone or tablet to calibre
charles.haleys.org/calibre
chaley is offline   Reply With Quote