I am new here and dont know whether this is the right place to ask my question but here goes…
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.
Here is some example code taken from the RE:Lay Addon.
Run this code, select the Cube and activate the object context. A rollout called “RE:Lay 1.3” should contain a little arrow button. When you click it, you get a popup input area. This is basically a floating panel that you can program in the draw portion of the operator.
import bpy
from bpy.props import IntProperty, FloatProperty, StringProperty, BoolProperty, EnumProperty
# Create operator to to transfer the current selection to the list.
class OBJECT_OT_PopupInput(bpy.types.Operator):
bl_label = "Get Selection And Distribute In Time"
bl_description ="Replace the current target list with a new list of the objects in the current selection."
bl_idname = "relay.get_selection"
offset = IntProperty(name="Offset: ",description="The frame delay that accumulates as each item in the selection is added to the target list.",default=5,min=0,max=300)
rephrase_object = StringProperty(name="Name: ",description="Use this RE:Phrase object's characters to populate the target list. Leave blank to transfer current viewport selection to target list.",default="")
def invoke(self, context, event):
#Popup a dialog the user can interact with.
wm = context.window_manager
return wm.invoke_props_dialog(self)
def draw(self,context):
layout = self.layout
layout.prop(self,"offset")
layout.separator()
box = layout.box()
layout.label(" RE:Phrase+ 1.3 Link:", icon="LINK_AREA")
layout.prop(self,"rephrase_object",icon="QUESTION")
layout.separator()
def execute(self, context):
print ("Put execution code here.")
return {'FINISHED'}
class OBJECT_PT_RELay(bpy.types.Panel):
bl_label = "RE:Lay 1.3"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "object"
def draw(self, context):
# Display operator button.
layout = self.layout
box1 = layout.box()
row = box1.row()
col = row.column(align=True)
col.operator("relay.get_selection", icon="RESTRICT_SELECT_OFF", text="")
#### REGISTER ####
def register():
# Panel
bpy.utils.register_class(OBJECT_PT_RELay)
bpy.utils.register_class(OBJECT_OT_PopupInput)
def unregister():
# Panel
bpy.utils.unregister_class(OBJECT_PT_RELay)
bpy.utils.unregister_class(OBJECT_OT_PopupInput)
#if __name__ == '__main__':
register()