Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

input dialog box blender

How to make a simple entry dialog box (like in the image) in blender and processing the text entered through python.I am unable to find any good tutorial on this.

simple entry box

like image 519
Vaibhav Avatar asked Mar 24 '13 04:03

Vaibhav


1 Answers

For the dialog box the answer from how to show a message from a blender script? might be a starting point.

But I think a better approach is integrating input into the panel like e.g.
String example

To do this you have to add a StringProperty to your add-on and place it inside your panel (see Addon Tutorial for more information). The basic steps are:

def draw(self, context) :
    col = self.layout.column(align = True)
    col.prop(context.scene, "my_string_prop")

...

def register() :
    bpy.types.Scene.my_string_prop = bpy.props.StringProperty \
      (
        name = "My String",
        description = "My description",
        default = "default"
      )

...

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

...

You can access the string by context.scene.my_string_prop

There is another mode to integrate input. When you add for example a text to your scene you can change the parameters after the operator has been called and see the changes immediately:

Add text object

Changing Location will move the newly created text object at another place. I haven't worked with this but it should be similar to the code above.

like image 91
Kay Avatar answered Oct 22 '22 08:10

Kay