I have created an add-on but I can't apply my own icon to the operators in this add-on.
Is there any easy way to implement this?
Or do I need to add the icon to an SVG file?
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It only takes a minute to sign up.Sign up to join this community
You can only use already available icons, too see which are available enable the Icons add-on. A panel with all icons will be displayed in the text editor properties (or python console). The name of the icons is shown in a tooltip.
You can use the icon attribute like:
row = layout.column(align=True) row.operator('id_name', icon='QUESTION')
Custom icons require compilation which is off-topic here but you could find a discussion on custom icons at this BA thread.
Possibly outdated information on how to integrate custom icons you find in the Wiki. There is descibed that all icons are stored in a single .png file which explains that you can't use SVG or any other format.
If your addon draws using opengl (via the
bgl module) you can draw your own images directly, however this is not accessible while drawing typical buttons & layouts.
You can however do this from: (http://www.blender.org/documentation/blender_python_api_2_69_release/bpy.types.Space.html?highlight=draw_handler_add#bpy.types.Space.draw_handler_add) unfortunatly using these callbacks is currently undocumented but you can see examples in scripts distributed with blender.