Post #780: :
bl_idname = "pme.my_input_box"
bl_label = "Input Box"
bl_options = {'INTERNAL'}
bl_property = "value"
on_execute = None
prev_value = ""
value = bpy.props.StringProperty()
def draw(self, context):
self.layout.prop(self, "value", "")
def execute(self, context):
if PME_OT_my_input_box.on_execute:
PME_OT_my_input_box.on_execute(self.value)
PME_OT_my_input_box.prev_value = self.value
return {'FINISHED'}
def invoke(self, context, modal):
return context.window_manager.invoke_props_dialog(self)
def input_box(func):
if not hasattr(bpy.types, "PME_OT_my_input_box"):
bpy.utils.register_class(PME_OT_my_input_box)
PME_OT_my_input_box.on_execute = func
bpy.ops.pme.my_input_box(
'INVOKE_DEFAULT', value=PME_OT_my_input_box.prev_value)
def my_function(value):
print(value)
And use it in Command tab:
from .scripts.input_box import input_box, my_function; input_box(my_function)
You can edit my_function ‘s code or replace it with some other function.