UI: It's not possible to add a separator to EnumProperty via Python #68260
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#68260
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
Operating system: Win 10
Graphics card: GTX 1070
Blender Version
Broken: 2.81
9620b8f6bb
and earlierShort description of error
Currently it is not possible to add a separator to EnumProperty via python.
What
Separator in EnumProperty is EnumPropertyItem which looks like that:
Such items are used for example in Cycles Math node (defined in C):
Why
However, currently it's not possible to make an EnumPropertyItem from python with required
sepr.name = NULL
(or with other field equal to nullptr).Part that is responsible for checking if an item is a separator is:
/source/blender/editors/interface/interface.c:ui_def_but_rna__menu
It uses
item->identifier- [x] == 0
anditem->name == nullptr
checks to determine if an item is a separator. (Butitem->name
will never benullptr
if it's created through python).Code for parsing EnumPropertyItem from python object:
_PyUnicode_AsStringAndSize
(which isPyUnicode_AsUTF8AndSize
) never returnsNULL
unless an error occurred.Solution
Add check for
item->name = empty string
inui_def_but_rna__menu
. That won't change the behaviour of existing nodes (which useidentifier- [x] ==0 && name == nullptr
) but will enable separator creation from python via tuple ("", "", "", "", 0).Added subscriber: @ixd
Patch: https://developer.blender.org/D5414
This issue was referenced by
916e51a407
Changed status from 'Open' to: 'Resolved'
Added subscriber: @RomboutVersluijs
Im tried using this in an enum menu and it divides dropdown into two parts? I also tried with ("", "", "", "", 0) but shows the same. Leaving out 0 returns error. Using bl2.82 on OSX
It seems it makes columns using that, not the separator as does with a menu
I did a test making the enum longer, repeated it 3 times. It results in 4 columns.
BLender API shows a different solution i just noticed.
See at the bottom, now using None it does work
PS i noticed some of Blender enum menu's also show this weird horizontal tabbing. For instance in Preferences > Addons > Sort Menu
Perhaps here its intentional since its probably more clear to read like this compared to a big list. But it looks kinda sloppy, its not aligning nice