Springen naar inhoud


Foto

Loading plugin pixmaps from skin path first, then fallback to plugin path - What's the best way to do it?


  • Please log in to reply
Geen reacties in dit onderwerp

#1 nautilus7

  • Senior Member
  • 229 berichten

+6
Neutral

Geplaatst op 11 november 2019 - 23:34

So, let's say a plugin needs to load some pixmaps for its skin. It can look up in the plugin director to load the pixmaps provided by the plugin, or look up in the skin directory to load the pixmaps provided by the skin.

 

This could be done like this:

# first check if current skin provides the icon
icon = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "icons/pluginName/icon.png"))

# fallback to icon supplied by the plugin
if icon is None:
     icon = LoadPixmap(resolveFilename(SCOPE_CURRENT_PLUGIN, "pluginName/icons/icon.png"))

The above work fine, but if the skin does not provides the icon, then we get an message in the debug log (icon not found)... Is there a way to do the same, but without getting the error message in the log?

 

In general, is there a more efficient or faster way to do it? 




1 gebruiker(s) lezen dit onderwerp

0 leden, 1 bezoekers, 0 anonieme gebruikers