1
$\begingroup$

Short version: What does the bl_space_type value "EMPTY" mean in the context of bpy.types.Panel?

Long version:

I'm doing a deep(ish) dive into the Blender Python API. Currently I'm studying bpy.types.Panel in the hopes of improving the panels in my add-ons. One of the standard fields in Panel classes is bl_space_type. The manual has a list of space types (‘EMPTY’, ‘VIEW_3D’, IMAGE_EDITOR’, ‘NODE_EDITOR’, ‘SEQUENCE_EDITOR’, ‘CLIP_EDITOR’, ‘DOPESHEET_EDITOR’, GRAPH_EDITOR’, ‘NLA_EDITOR’, ‘TEXT_EDITOR’, ‘CONSOLE’, ‘INFO’, ‘TOPBAR’, ‘STATUSBAR’, ‘OUTLINER’, ‘PROPERTIES’, ‘FILE_BROWSER’, ‘SPREADSHEET’, and ‘PREFERENCES’).

Most of the space types correspond to to the various editors and make perfect sense as such and I understand how bl_space_type is used in a panel. I've done the obvious web search for "Blender python bl_space_type EMPTY'; but the search has turned up (sorry for the pun) empty. None of the proposed "Similar questions" seem to shed any light on the issue.

I am speculating that 'EMPTY', is used as a stand in for "any space type at all"; but I can't find anything that confirms this.

Does anyone know what the 'EMPTY' bl_space_type is used for?

$\endgroup$

2 Answers 2

2
$\begingroup$

I think it doesn't serve any purpose in the context of panels.

It looks like it is mainly (only) used in the keymap definitions.

From what I could tell it means it's supposed to be shared by several space types.

For instance every space type can have Window shortcuts, Screen shortcuts, etc.

And Clip, Frame manipulation, Mask editing, Grease Pencil, etc. do not have a particular space type associated with them.

enter image description here

$\endgroup$
7
  • $\begingroup$ [bl_space_type](docs.blender.org/api/current/…} manual entry lists the space types that are used in Panel. Every one of them except 'EMPTY' is associated with an editor, as described in the manual. They're used to identify what editors the panel is associated with. It's the usage in the Panel class that I'm asking about.. $\endgroup$ Commented Jan 4, 2022 at 16:18
  • $\begingroup$ Yeah I do understand that, but what I tried to explain is the enum used to define the possible values in the panel class defintion is shared with all the other parts of Blender which need it too. See github.com/blender/blender/blob/master/source/blender/makesrna/… and github.com/blender/blender/blob/master/source/blender/makesrna/… so the 'EMPTY' enum value is a leftover quirk from python API, it's not supposed to be used by panels (at least imo) $\endgroup$
    – Gorgious
    Commented Jan 4, 2022 at 16:29
  • $\begingroup$ Yes, I realize that the enum has other values. That's why I specifically called out the set used by bl_space_type. 'EMPTY' is one of the included ones. So what is it used for in this context? $\endgroup$ Commented Jan 4, 2022 at 16:32
  • 1
    $\begingroup$ It's not supposed to be used in any capacity for panels, it's written out in the documentation because it's generated automatically from the C code but its single use is for keymap definitions, which share the same enum items. It's like a global function to fetch space type items that's used by several C files, so they're not re-defined in every module. See the call to rna_enum_space_type_items here github.com/blender/blender/blob/master/source/blender/makesrna/… $\endgroup$
    – Gorgious
    Commented Jan 4, 2022 at 16:36
  • 1
    $\begingroup$ Alright, thanks for bearing with me, I learnt a thing or two along the way too. Cheers :) $\endgroup$
    – Gorgious
    Commented Jan 4, 2022 at 17:16
1
$\begingroup$

Thanks to a comment on this answer I was pointed in the right direction.

Internally, the 'EMPTY' string is converted into SPACE_EMPTY. SPACE_EMPTY is used in the C code for various purposes, including as the space type for file dropboxes and for newly created empty screens. It has many other uses related to versioning and detecting uninitialized data; but these are the only two related to the UI.

It is not meant for external use and only included for completeness.

$\endgroup$

You must log in to answer this question.

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