Try to set an invalid UI type to generate an error message
try:
bpy.context.area.ui_type = ''
except TypeError as e:
Extract the valid UI types from the error message
match = re.search(r'not found in \((.*)\)', str(e))
if match:
editor_types = match.group(1).split(', ')
editor_types = [editor_type.strip("'") for editor_type in editor_types]
else:
raise e
Get the labels of the editor types
editor_labels = [bpy.types.Space.subclasses()[i].bl_rna.name for i in editor_types]
Print the editor types and their labels
for editor_type, editor_label in zip(editor_types, editor_labels):
print(f'Editor Type: {editor_type}, Label: {editor_label}')
Dynamically get the list of Blender area types
import bpy import re
Try to set an invalid UI type to generate an error message
try: bpy.context.area.ui_type = '' except TypeError as e:
Extract the valid UI types from the error message
Get the labels of the editor types
editor_labels = [bpy.types.Space.subclasses()[i].bl_rna.name for i in editor_types]
Print the editor types and their labels
for editor_type, editor_label in zip(editor_types, editor_labels): print(f'Editor Type: {editor_type}, Label: {editor_label}')