1
$\begingroup$

I am trying to make a custom panel with two text box which will be assigned to two different lists. However in my panel tool bar, whenever i change one text box, that other automatically changes. I know this is because I am calling both text boxes to "my_string_prop", but everytime i change that name, the text box disappears. Additionally, are the word in the parenthesis key words and if show does anyone know where i can will the list for them.


import bpy


class LayoutDemoPanel(bpy.types.Panel):
    """Creates a Panel in the scene context of the properties editor"""
    bl_label = "Layout Demo"
    bl_idname = "SCENE_PT_layout"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'
    #bl_context = "scene"

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

        scene = context.scene



        row = layout.row()
        row.label(text="X-Points:")
        row = layout.row()
        row.prop(context.scene, "my_string_prop")
        list1 = [context.scene.my_string_prop]
        print (list1)

        row = layout.row()
        row.label(text="Y-Points:")
        row = layout.row()
        row.prop(context.scene, "my_string_prop" )
        list2 = [context.scene.my_string_prop]
        print(list2)

def register():
    bpy.utils.register_class(LayoutDemoPanel)


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


if __name__ == "__main__":
    register()
$\endgroup$

1 Answer 1

1
$\begingroup$

As both items refer to the property my_string_prop they will show the same data. The name of the property used has to exist, if you change the name and it doesn't exist it will not draw the textbox.

To add new properties to the scene object you should add the property in your register function.

bpy.types.Scene.my_string_prop2 = bpy.props.StringProperty(name="String2")

To get a list of items you can use prop_search

row.prop_search(context.scene, "my_string_prop2", bpy.data, "objects")

That will show a list of object names to choose from.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.