Docs: move WindowManager.fileselect_add descriptions into an example

- Allow for formatting and expanded descriptions.
- Clarify the expected types of each property.
This commit is contained in:
Campbell Barton
2025-04-25 10:18:36 +10:00
parent 2d4290f285
commit 0314f9318c
2 changed files with 23 additions and 7 deletions

View File

@@ -0,0 +1,20 @@
"""
This method is used from the operators ``invoke`` callback.
On success they should return ``{'RUNNING_MODAL'}`` otherwise ``{'CANCELLED'}``.
Accepting the file selector will run the operators ``execute`` callback.
The following properties are supported:
``filepath``: ``bpy.props.StringProperty(subtype='FILE_PATH')``
Represents the absolute path to the file.
``dirpath``: ``bpy.props.StringProperty(subtype='DIR_PATH')``
Represents the absolute path to the directory.
``dirpath``: ``bpy.props.StringProperty(subtype='DIR_PATH')``
Represents the filename without the leading directory.
``files``: ``bpy.props.CollectionProperty(type=bpy.types.OperatorFileListElement)``
When present in the operator this collection includes all selected files.
``filter_glob``: ``bpy.props.StringProperty(default="*.ext")``
When present in the operator and it's not empty,
it will be used as a file filter (example value: ``*.zip;*.py;*.exe``).
"""

View File

@@ -876,13 +876,9 @@ void RNA_api_wm(StructRNA *srna)
PropertyRNA *parm;
func = RNA_def_function(srna, "fileselect_add", "WM_event_add_fileselect");
RNA_def_function_ui_description(
func,
"Opens a file selector with an operator. "
"The string properties 'filepath', 'filename', 'directory' and a 'files' "
"collection are assigned when present in the operator. "
"If 'filter_glob' property is present in the operator and it's not empty, "
"it will be used as a file filter (example value: '*.zip;*.py;*.exe').");
/* Note that a full description is located at:
* `doc/python_api/examples/bpy.types.WindowManager.fileselect_add.py`. */
RNA_def_function_ui_description(func, "Opens a file selector with an operator.");
rna_generic_op_invoke(func, 0);
func = RNA_def_function(srna, "modal_handler_add", "rna_event_modal_handler_add");