How to create text input field with Blender Python API? I need to create a couple of text input fields for my Blender addon. When the script starts, the first text should be replaced by the second one. So I need to create 2 text input fields and to have access to the data entered in these fields with Python API.
Does someone know how to do it? Tried to google something, but didn't succeed.
import bpy
from bpy.props import StringProperty

mystr: StringProperty(name=&quot;Enter something:&quot;)


class HelloWorldPanel(bpy.types.Panel):
    bl_idname = &quot;OBJECT_PT_hello_world&quot;
    bl_label = &quot;Hello! World.&quot;
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = &quot;object&quot;

def draw(self, context):
    self.layout.label(text=&quot;He that endureth to the end shall be saved.&quot;)
    self.layout.prop(&quot;mystr&quot;)
    
def register():
    bpy.utils.register_class(HelloWorldPanel)

def unregister():
    bpy.utils.unregister_class(HelloWorldPanel)

if __name__ == &quot;__main__&quot;:
    register()
You would have to register a Panel and as much StringProperties as you like. In order to display your properties on the panel, call layout.prop().
Following demo is based on  How to create a custom UI?
import bpy

from bpy.props import (StringProperty,
                       PointerProperty,
                       )
                       
from bpy.types import (Panel,
                       PropertyGroup,
                       )


# ------------------------------------------------------------------------
#    Scene Properties
# ------------------------------------------------------------------------

class MyProperties(PropertyGroup):

    foo: StringProperty(
        name=&quot;Foo&quot;,
        description=&quot;:&quot;,
        default=&quot;&quot;,
        maxlen=1024,
        )

    bar: StringProperty(
        name=&quot;Bar&quot;,
        description=&quot;:&quot;,
        default=&quot;&quot;,
        maxlen=1024,
        )


# ------------------------------------------------------------------------
#    Panel in Object Mode
# ------------------------------------------------------------------------

class OBJECT_PT_CustomPanel(Panel):
    bl_label = &quot;My Panel&quot;
    bl_idname = &quot;OBJECT_PT_custom_panel&quot;
    bl_space_type = &quot;VIEW_3D&quot;   
    bl_region_type = &quot;UI&quot;
    bl_category = &quot;Tools&quot;
    bl_context = &quot;objectmode&quot;   

    @classmethod
    def poll(self,context):
        return context.object is not None

    def draw(self, context):
        layout = self.layout
        scene = context.scene
        mytool = scene.my_tool

        layout.prop(mytool, &quot;foo&quot;)
        layout.prop(mytool, &quot;bar&quot;)
        layout.separator()

# ------------------------------------------------------------------------
#    Registration
# ------------------------------------------------------------------------

classes = (
    MyProperties,
    OBJECT_PT_CustomPanel
)

def register():
    from bpy.utils import register_class
    for cls in classes:
        register_class(cls)

    bpy.types.Scene.my_tool = PointerProperty(type=MyProperties)

def unregister():
    from bpy.utils import unregister_class
    for cls in reversed(classes):
        unregister_class(cls)
    del bpy.types.Scene.my_tool


if __name__ == &quot;__main__&quot;:
    register()