I'm trying to create an action for the add menu in the video sequencer. I need it to open a file browser so the user can select a file to add. To do this I use ImportHelper, which works great if I trigger my action from the menu at the bottom of the Video Sequence Editor window. However, if I type ShiftA and then select the same action from the menu that pops up, the file browser doesn't show up. Is this a bug in Blender, or am I just missing something?
Here's a slightly modified version of the operator_file_import python template that exhibits this behavior:
import bpy
from bpy_extras.io_utils import ImportHelper
from bpy.types import Operator
class ImportSomeData(Operator, ImportHelper):
"""This appears in the tooltip of the operator and in the generated docs"""
bl_idname = "sequencer.some_data"
bl_label = "Import Some Data"
def execute(self, context):
print(self.filepath)
return {"FINISHED"}
# Only needed if you want to add into a dynamic menu
def menu_func_import(self, context):
self.layout.operator(ImportSomeData.bl_idname, text="Text Import Operator")
def register():
bpy.utils.register_class(ImportSomeData)
bpy.types.SEQUENCER_MT_add.append(menu_func_import)
def unregister():
bpy.utils.unregister_class(ImportSomeData)
bpy.types.SEQUENCER_MT_add.remove(menu_func_import)
if __name__ == "__main__":
register()