user-interfaceblenderbpy

Blender - Inserting a line of text using bpy


I'm designing a simple GUI for a Blender 2.80 plug-in. I've created a dialog box to enter some data:

enter image description here

class ExportFDSCloudHPC(Operator):

    bl_idname = "..."
    bl_label = "Dialog Box"
    bl_description = "..."

    data1 = bpy.props.StringProperty(
        name = "Data 1",
        default = "..."
    )

    data2 = bpy.props.StringProperty(
        name = "Data 2",
        default = "..."
    )

    data3 = bpy.props.StringProperty(
        name = "Data 3",
        default = "..."
    )
    
    def draw(self, context):
        col = self.layout.column(align = True)
        col.prop(self, "data1")

        col = self.layout.column(align = True)
        col.prop(self, "data2")

        col = self.layout.column(align = True)
        col.prop(self, "data3")

    def execute(self, context):
        ...

I would like to add a line of text above Data 1 with a message that has the same length as the dialog box. It's possible?


Solution

  • Add label() in draw() as you adding column:

    def draw(self, context):
        self.layout.label(text="text")
        col = self.layout.column(align = True)
    

    Here is label documentation