What are the new class naming conventions in Blender's 2.80 Python API for add-ons?
It says here:
This constraint applies to the
bl_idname
of each class (or the class name which uses it if no bl_idname is defined in the class).These are:
UPPER_CASE_{SEPARATOR}_mixed_case
, in the case of a menu the regular expression is:[A-Z][A-Z0-9_]*_MT_[A-Za-z0-9_]+The separator for each class is listed below:
- Header ->
_HT_
- Menu ->
_MT_
- Operator ->
_OT_
- Panel ->
_PT_
- UIList ->
_UL_
Valid Examples:
OBJECT_OT_fancy_tool
SOME_HEADER_HT_my_header
PANEL123_PT_myPanel
(lower case is preferred but mixed case is supported).At the time of writing this, names that don't conform to this convention will produce a warning on startup. Eventually we will make this into an error, eg:
Warning: 'Oscurart Files Tools' doesn't contain '_PT_' with prefix & suffix Warning: 'Oscurart Overrides' doesn't contain '_PT_' with prefix & suffix Warning: 'Oscurart Animation Tools' doesn't contain '_PT_' with prefix & suffix
So this might mean that the bl_idname
should actually be something like:
"object.MY_ADDON_OT_some_object_operator"
It still requires a '.' to be there so object.OBJECT_OT_something_something
does not seem to make much sense to me. Does this actually apply to bl_idname
? Could someone explain in more detail the idea behind this and how these conventions should be followed in practice?