https://b3d.interplanety.org/en/multiline-text-in-blender-interface-panels
Blender目前没有多行编辑器,本例使用切割文字,再分别用layout.label展示
代码
from bpy.types import Panel
from bpy.utils import register_class
import textwrap
def _label_multiline(context, text, layout):
chars = int(context.region.width / 7) # 7pix/字符
wrapper = textwrap.TextWrapper(width=chars)
text_lines = wrapper.wrap(text=text)
# 遍历分割的字符,然后用label显示
for text_line in text_lines:
layout.label(text=text_line)
# N面板
class TEST_PT_private(Panel):
bl_idname = 'TEST_PT_test'
bl_label = 'MULTILINE TEXT'
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = 'TEST'
def draw(self, context):
layout = self.layout
text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut laborein voui officia deserunt mollit anim id est laborum.'
_label_multiline(
context=context,
text=text,
layout=layout
)
register_class(TEST_PT_private)