Blender's Python API offers a comprehensive toolkit to create custom add-ons, extending the functionality and enhancing the user experience. One of the key aspects of a well-designed add-on is a visually appealing and consistent user interface. This article will introduce you to Blender's built-in icons available through the
bpy.app.icons module and demonstrate how to use them in your add-ons.
bpy.app.icons is a module in Blender's Python API that provides access to the built-in icons used throughout Blender's interface. These icons represent various actions, objects, and elements, and can be used in your add-ons to create a user interface that matches Blender's native look and feel.
The module itself does not provide any functions or classes for direct interaction. Instead, you can reference the icons by their names as strings when defining UI elements like buttons, labels, or menus.
Implementing Icons in Your Add-ons
To use icons in your add-ons, pass the icon name as a string to the
icon parameter of UI elements. Let's explore a simple example of how to use built-in icons in a Blender add-on.
Example: Icon Usage in a Blender Add-on
The following example demonstrates how to create a panel in the 3D Viewport's sidebar with buttons that have icons from
In this example, we used the built-in icons
DUPLICATE. You can use any available icons in your add-ons in a similar manner.
Finding Available Icons
To see a list of available icons, you can use the Icon Viewer add-on that comes with Blender by default but is not enabled. To enable the Icon Viewer add-on, go to Edit > Preferences > Add-ons and search for "Icon Viewer". Enable the checkbox next to the Icon Viewer add-on. Once enabled, you'll find the Icon Viewer in the Python Console's sidebar.
bpy.app.icons is a read-only module, and you cannot add custom icons through it.