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="Foo",
description=":",
default="",
maxlen=1024,
)
bar: StringProperty(
name="Bar",
description=":",
default="",
maxlen=1024,
)
------------------------------------------------------------------------
Panel in Object Mode
------------------------------------------------------------------------
class OBJECT_PT_CustomPanel(Panel):
bl_label = "My Panel"
bl_idname = "OBJECT_PT_custom_panel"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "Tools"
bl_context = "objectmode"
@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, "foo")
layout.prop(mytool, "bar")
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 == "main":
register()
getattr(..)==>layout.prop(obj, propertyname)expects the object and the property name. Either annotate your own class (as answered below by @brockmann), or define it on the class, eg for a scene propertybpy.types.Scene.foo = StringProperty(...)to make it a property of any instance of a blender scene.layout.prop(context.scene, "foo")– batFINGER Nov 26 '20 at 10:01