3
$\begingroup$

Is there a way to customize the export button label in the File Dialog? Currently, the button always uses the bl_label of the operator, but I’d like to set a different label specifically for the export button while keeping bl_label unchanged for the F3 search. Is there a way to achieve this?

import bpy

class EXPORT_OT_TestExportOperator(bpy.types.Operator):
    bl_idname = "export.test_export_operator"
    bl_label = "I only need this label for F3 search but not for the export button"  # This text will appear as the file dialog button

    filepath: bpy.props.StringProperty(subtype="FILE_PATH")

    def execute(self, context):
        return {'FINISHED'}

    def invoke(self, context, event):
        context.window_manager.fileselect_add(self)

        # Attempts to override/change button label (this doesn't work)
        self.bl_label = "Custom Export Button"
        context.window_manager.operators[-1].bl_label = "Custom Export Button"

        return {'RUNNING_MODAL'}

def menu_func_export(self, context):
    self.layout.operator(EXPORT_OT_TestExportOperator.bl_idname, text="Test Export Issue")

def register():
    bpy.utils.register_class(EXPORT_OT_TestExportOperator)
    bpy.types.TOPBAR_MT_file_export.append(menu_func_export)

def unregister():
    bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
    bpy.utils.unregister_class(EXPORT_OT_TestExportOperator)

if __name__ == "__main__":
    register()
$\endgroup$
3
  • $\begingroup$ I don't think it's possible but the Test Export Issue label can be used for the F3 search. $\endgroup$ Commented Feb 17 at 2:29
  • $\begingroup$ @Karan thank you for your help! Oki I'm fine to use that instead, how can I accomplish this? $\endgroup$ Commented Feb 17 at 2:44
  • 1
    $\begingroup$ FWIW a bit similar to blender.stackexchange.com/q/231876/86891 spoiler I didn't find a way to modify this button. $\endgroup$ Commented Feb 17 at 12:57

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.