Coming from “real” programming languages you will be sadly disappointed at the current state of GUI elements as implemented in Blender. Don’t think of them as objects that you can program. They are simply things you can make appear in a panel. There is no text area, just a place where you can type a single line string. Multi-line is currently not supported.
Here is the way I do it. I create a class that encompasses all the variables I need in their various types (int, float, string). Then add that class so it appears as properties for all objects in Blender. Each of the properties can have an event handler associated with it. So you can process specific fields in its own event space. These event handlers are defined in the class itself.
Here is an example that will add an int, float and string to each and every object in Blender. Run the script and select the Object context and scroll to the bottom of the panel. You should see 3 fields. When you change the value of the fields, an event is generated and the value of the field is printed in the Blender console (not python console) which is hidden by default. Unhide the console under the Help menu along the top of the app. Help/Toggle System Console.
import bpy
def updateIntParameter(self,context):
# This def gets called when one of the properties changes state.
print(self.my_int)
def updateFloatParameter(self,context):
# This def gets called when one of the properties changes state.
print(self.my_float)
def updateStringParameter(self,context):
# This def gets called when one of the properties changes state.
print(self.my_string)
class cls_IntFloatString(bpy.types.PropertyGroup):
# The properties for this class which is referenced as an 'entry' below.
my_int = bpy.props.IntProperty(name="My Integer", description="Integer.", default=1, min=0, max=12, update=updateIntParameter)
my_float = bpy.props.FloatProperty(name="My Float", description="Float.", default=1.0, min=0.000, max=18.0, step=3, precision=4, options={'ANIMATABLE'}, subtype='FACTOR', unit='NONE', update=updateFloatParameter)
my_string = bpy.props.StringProperty(name="My String", description="Type your string here.", update=updateStringParameter)
bpy.utils.register_class(cls_IntFloatString)
# Add these properties to every object in the entire Blender system (muha-haa!!)
bpy.types.Object.My_List_Index = bpy.props.IntProperty(min= 0,default= 0)
bpy.types.Object.My_List = bpy.props.CollectionProperty(type=cls_IntFloatString)
class IntFloatStringPanel(bpy.types.Panel):
bl_label = "Int Float String"
bl_idname = "OBJECT_PT_hello"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "object"
def draw(self, context):
layout = self.layout
obj = context.object
l = len(obj.My_List)
if l > 0:
entry = obj.My_List[obj.My_List_Index]
box1 = layout.box()
row1 = box1.row()
row1.label(" Label:", icon='INFO')
# Display properties for each type.
box1.prop(entry, "my_string", icon='OBJECT_DATAMODE')
box1.prop(entry, "my_int")
box1.prop(entry, "my_float")
else:
# This list is zero length, so let's add one.
collection = obj.My_List
collection.add()
def register():
bpy.utils.register_class(IntFloatStringPanel)
def unregister():
bpy.utils.unregister_class(IntFloatStringPanel)
if __name__ == "__main__":
register()
In this example you would put your parse code in the def updateStringParameter.