Packing external images
If we use image files for our add-on, we can create a folder in the structured_addon
directory and name it pictures
. Since we are going to write a module for loading icons, this folder can contain a collection of image files.
In the ch6\addons\structured_addon\pictures
folder from the examples, we have pack_64.png
, a clipart representing a package, and smile_64.png
, the smiley face from the previous chapter:
Figure 6.5: The pictures used for this add-on are stored in a folder
Once all our images are in this folder, we can write the code to load them.
Writing an icon library
In Chapter 5, we wrote a function that loads a specific image file from disk. That worked great. Now that we are loading two icons, we can just use the same routine twice.
But now that we have an entire module for loading images, we can write a more sophisticated solution that works for any number of icons since it doesn’t rely on hardcoded...