I want to create a text box in Python to obtain the input text from the text box to provide data for my plugin, but I cannot find the function to create the text box. Currently, I can only create labels and buttons What I want enter image description here to achieve is a text box that can input text, as shown in Figure 3

enter image description here

enter image description here

enter image description here


1 Answer 1


You need to create a StringProperty

import bpy

class HelloWorldPanel(bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_label = "Hello World Panel"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_category = "Test"

    def draw(self, context):
        layout = self.layout

        layout.prop(context.scene, 'input')

def register():
    bpy.types.Scene.input = bpy.props.StringProperty(name='Input')

def unregister():
    del bpy.types.Scene.input

if __name__ == "__main__":

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .