To add an icon, you need to write “icon = hoge” as the third argument of “pie.operator()”.
However, I don’t know the name of the toolbar icon.
I used an add-on called “Develolpment: Icon Viewer,” but it could not tell me the name of the icon in the toolbar.
Also, I searched Google and found similar questions to mine, but it didn’t tell me what I needed to do…
Can anyone tell me how to know the name of the toolbar icon when specifying it in Python code?
You need to take a look at “WM_OT_toolbar_fallback_pie” as an example.
Check “draw_fallback_tool_items_for_pie_menu” in space_toolsystem_common.py,
you will need to use “icon_value” rather than “icon” argument.
Right-clicking on the icon did not bring up the “Edit source” option.
This image shows the screen when you right-click on any icon.
I’m using Blender version 2.91.2, is it not possible to show the “Edit source”?
Or am I doing something wrong?
Thanks for the reply.
I used “Development: Icon Viewer” to look at the icon list, but I couldn’t find the toolbar icon I wanted to use in it.
Does this mean that I can’t use the icons in the toolbar myself?
I looked at the site you gave me.
I found out that there are two types of icons in Blender and that the large size colored icons I’m trying to use are .dat files in [2.91\datafiles\icons].
But I couldn’t find anything more than that…
I tried right-clicking on the icon I want to use in the Blender toolbar and going to “Edit source” to see the code, but I’m not sure what code I need to write to use it in the pie menu.
See the function: _icon_value_from_icon_handle(icon_name)
In the file: scripts\startup\bl_ui\bl_ui\space_toolsystem_common.py
I modified the function to print the Tool Panel icon names to the system console as follows:
ops.transform.translate
ops.transform.rotate
ops.transform.resize
ops.transform.transform
ops.gpencil.draw
ops.view3d.ruler
ops.mesh.primitive_cube_add_gizmo
ops.generic.select_box
ops.generic.cursor
Thank you very much.
I’m really sorry for the delay in replying.
I looked at the _icon_value_from_icon_handle function in space_toolsystem_common.py.
By modifying it, do you mean that I should write the code you gave me somewhere in the _icon_value_from_icon_handle function?
I don’t recommend modifying the code in _icon_value_from_icon_handle, my intention was to direct you to where and how I retrieved the names of the icons that you are interested in so that you might examine the script in \2.93\scripts\startup\bl_ui\space_toolsystem_common.py to see how the icons are retrieved.
↑By writing it like this, I was able to successfully get the toolbar icon!
Perhaps someone else told me about this a while ago, but I didn’t understand it at the time due to my lack of understanding.
Sorry again when I said it was resolved.
I have one more question.
I don’t know how to check the icon_value of the icon in the toolbar.
I know “ops.generic.select_box” etc. because you wrote it in your reply earlier.
However, I don’t know the icon_value for other tools such as knife cut.
I looked at space_toolsystem_common.py and the icon_value for the toolbar is “icon_value = ToolSelectPanelHelper._icon_value_from_icon_handle(item.icon)”.
I found out that the icon_value of the toolbar is related to
However, I don’t know the specific name of the icon_value.
How can I find out the specific name of the icon_value?
Thank you.
Now I see that the names of the icon_values, such as “ops.generic.select_box.dat” are
“D:\Program Files\blender-2.91(MyConfig)\2.91\datafiles\icons”
The name of the icon_value is the same as the file name in
Someone else had told me the same thing before, but I couldn’t figure it out, so…