4
$\begingroup$

I'm sure this must exist, but all of the information is hard to navigate:

I'm putting together QoL custom workflow tools as a way of getting started in Python scripting for Blender, and I'm finding that much less of my time is being used writing or even figuring out the structure of code I want to put together than hunting down syntax.

For instance: I found this very helpful for figuring out the structure of code if I want to append a custom button to a particular editor's header. What I DIDN'T find was what to write if I wanted to put it in the dope sheet header, rather than that of the shader editor. Like it looks like the name for the shader is NODE_HT_; what's the name for the Dope Sheet? Or the Video Sequencer?

I'm sure I'll eventually find it floating around somewhere, but there's got to be a resource somewhere that just lists how to refer to each of them. I saw that it was in bpy.types. so I tried to use TAB to at least get the list of potential options, but there were so many returned that it wouldn't let me scroll up through all of them.

Where can I find this info?

$\endgroup$

1 Answer 1

5
$\begingroup$

I don't know of a list of every possible name of UI element. But there are some lists for some elements. For example:

Space Type Items — Blender Python API

You can also easily identify things in Blender itself, using the Developer Extras and Python Tooltips. You can enable them in the Preferences > Interface tab:

enter image description here

Tooltips

Python tooltips will display when hovering UI elements. Hovering a menu will show its menu class (if your menu opens instead, disable "Open on mouse over" in Preferences > Interface tab).

enter image description here

Properties will show their full data path, operator their method name, etc.

enter image description here

Developer Extras

Developer Extras add a lot of usefull things for devs, like the operator search or copying python commands. And in particular for our topic:
It lets you RMB RMB a UI element like the node editor header and select "Edit Source", and it will open the corresponding python file describing the UI of that element, and it will even jump to the corresponding line of code.

If you know a bit how BPY works, you will easily find what you need there:

node editor header python name

May it be class names, idname, space types, ...

Edit Operator Source

UI elements called by operators don't have the Edit Source contextual menu.
But there is an addon shipped with Blender that allows you to do exactly that:

Edit Operator Source — Blender Manual

Enable it in the preferences, open the text editor's sidebar, click the Edit Operator button, paste the operator method (without bpy.ops.) and click it in the search result. It will show the different elements available for that operator, chose the one that you need, and it will open in the text editor.

NOTE (2023-07-06):
This addon seems to have a bug (recursion errors) when other addons such as Animaide are enabled. If you encounter such an issue, try disabling Animaide, rebooting Blender and trying again.
Bug reports were made on both addons, with a proposed patch for Edit Operator Source. You can follow up the bug reports here:

Blender's output

Blender have a few ways to tell you what's going on:

Info Editor

The Info editor logs executed operators, warnings and error messages. Logged reports can be selected by clicking on them. To select multiple reports, hold down Shift-LMB.

Info Editor — Blender Manual

enter image description here

Python Console Editor

The Python Console is a quick way to execute commands, with access to the entire Python API, command history and auto-complete.

Python Console — Blender Manual

enter image description here

System Console

Menu Window > Toggle System Console, or run Blender via console/terminal.

The Console Window, also called a Terminal, is an operating system text window that displays messages about Blender’s operations, status, and internal errors.

Introduction — Blender Manual

enter image description here

$\endgroup$
4
  • 1
    $\begingroup$ I had no idea at all about that last bit and it's EXACTLY what I didn't even know I needed, this is gonna make everything run smoother. Thanks! $\endgroup$ Jun 27, 2023 at 0:11
  • 1
    $\begingroup$ Glad it helped! Don't forget to accept my answer by clicking the checkmark ✔️ icon below the vote arrows. $\endgroup$
    – Lauloque
    Jun 27, 2023 at 0:15
  • 1
    $\begingroup$ You can also hover your mouse over a menu button to see the menu class name in the tooltip. You do need to disable "Open on mouse over" in the menus settings in the Interface preferences $\endgroup$
    – Gorgious
    Jun 27, 2023 at 8:01
  • $\begingroup$ updated answer with more details and stuff to know $\endgroup$
    – Lauloque
    Jun 30, 2023 at 23:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .