Using Blender's Application Icons (bpy.app.icons) in Your Add-ons

Using Blender's Application Icons (bpy.app.icons) in Your Add-ons

Discover how to use Blender's built-in icons in your custom add-ons to create visually appealing and consistent user interfaces. Learn how to access and implement bpy.app.icons in your add-on's UI elements and find out where to locate the complete list of available icons.

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.

Understanding bpy.app.icons

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 bpy.app.icons.

Code

In this example, we used the built-in icons INFO, MESH_CUBE, MESH_UVSPHERE, MESH_CONE, and 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.

Remember that bpy.app.icons is a read-only module, and you cannot add custom icons through it. 

Leave a comment

All comments are moderated before being published.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.