2
$\begingroup$

In a recent question a user asks about setting relative / absolute paths from a subtype='DIR_PATH' string property. Made me recall, (actually thought I had asked this, couldn't find) re the ability to glob a subtype='FILE_PATH' string property.

When the file / dir path subtypes are set; to the layout is added a button to invoke the filebrowser.

layout.prop(ob, "file_path")

For the case of file path a button is added to open the filebrowser using bpy.ops.buttons.file_browse() This operator has all the "usual suspects" of an operator that invokes the file browser. (Akin to using ImportHelper, ExportHelper)

For example, if this was a regular operator in layout could

op = layout.operator("buttons.file_browse")
op.filter_python = True
op.use_relative = True.

to glob python files and make a relative path.

and AFAIK there is no way to

  1. When using subtype laid out as a property access and change the browse buttons operator properties

  2. Or not using subtype pass the string property name to the operator to re-use the operator eg

    row.prop(ob, "file_path") # without making it a file subtype op = row.operator("buttons.browse_file")

and have the result populate the property.

Was hoping to "unlock" somehow using button context as shown here adding an operator to the context menu (right click)., by setting a context pointer to "button_prop", but alas found myself going in circles. Or using a hack like a depsgraph update handler or a callback on FILEBROWSER space to set the operator props if it active, kinda emulating somewhat the check method in an ExportHelper operator

To paraphrase, is there a way to use the string property subtype FILE_PATH and glob the filebrowser invoked via the UI generated button?

$\endgroup$

0

You must log in to answer this question.

Browse other questions tagged .