FolderSelector#

class ansys.solutions.dash_super_components.FolderSelector(mode: FolderSelectorMode | None = None, aio_id: str | None = None, browse_button_props: dict[str, Any] | None = None, clear_button_props: dict[str, Any] | None = None, style: dict[str, Any] | None = None, options: dict[str, Any] | None = None, value: str | None = None)#

Bases: Div

A Dash component for browsing and selecting a directory.

FolderSelector is based on the Dash All-in-One (AIO) component pattern. It supports two operating modes:

  • Tkinter (FolderSelectorMode.TKINTER): native OS dialog; requires the tkinter package.

  • Bootstrap (FolderSelectorMode.BOOTSTRAP): browser-based modal with a tree view of the file system; works in headless or remote environments.

Bootstrap mode is a beta feature and is disabled by default. Applications can opt in by calling configure() with enable_beta_features=True.

When mode is not specified, and bootstrap beta is enabled, bootstrap is used when tkinter is unavailable or when the environment variable FOLDER_SELECTOR_REMOTE_DEPLOYMENT is set to true, 1, or yes; otherwise tkinter is used.

Note

The component must be placed inside a MantineProvider. For error notifications to work correctly, a dmc.NotificationContainer must also be present in the application layout. By default the container ID is "notification-container"; use configure() to change it.

Parameters:
modeFolderSelectorMode, optional

Operating mode. Use FolderSelectorMode.TKINTER for a native OS dialog or FolderSelectorMode.BOOTSTRAP for a browser-based modal. Bootstrap mode is available only when configure() was called with enable_beta_features=True. When omitted, the mode is selected automatically (see above).

aio_idstr, optional

Unique identifier for this component instance. A UUID is generated when not provided.

browse_button_propsdict, optional

Properties forwarded to the browse dmc.Button.

clear_button_propsdict, optional

Properties forwarded to the clear dmc.ActionIcon.

styledict, optional

CSS style properties applied to the component container.

optionsdict, optional

Additional configuration options:

  • default_path (str or pathlib.Path, optional): Path used as the default selected folder when nothing has been selected or the selection is cleared.

  • browse_from (str, optional): Root path for the file tree in Bootstrap

    mode. In Bootstrap mode, this value must be provided either via this option or via the FOLDER_SELECTOR_BROWSE_FROM environment variable.

  • topmost (bool, optional): If True, the tkinter dialog appears in the foreground. Default is True.

  • max_path_length (int, optional): Maximum allowed path length. Defaults to the system limit.

  • max_tree_depth (int, optional): Maximum folder depth to include in bootstrap mode. Default is 10.

  • max_children_per_node (int, optional): Maximum number of child

    folders included per tree node in Bootstrap mode. Default is 100.

  • display_field (dict, optional): Dict with an enabled key (bool) controlling whether the selected path is shown below the buttons, and an optional max_display_lines key (int) controlling how many lines the path text may span before being truncated with an ellipsis. When the path is truncated, hovering over the display field shows the full path in a tooltip. Default is {"enabled": True, "max_display_lines": 2}.

valuestr, optional

Preselected folder path. Populates the selected folder store upon component instantiation.

IDs

class ansys.solutions.dash_super_components.FolderSelector.FolderSelectorIds#

Bases: AIOIds

Provides IDs for the subcomponents of FolderSelector.

classmethod browse_button(aio_id: str | Wildcard) → dict[str, Any]#

Return the ID for the browse button.

Parameters:
aio_idstr or _Wildcard

The component’s unique identifier.

Returns:
dict[str, Any]

The unique ID dictionary for the browse button subcomponent.

classmethod clear_button(aio_id: str | Wildcard) → dict[str, Any]#

Return the ID for the clear button.

Parameters:
aio_idstr or _Wildcard

The component’s unique identifier.

Returns:
dict[str, Any]

The unique ID dictionary for the clear button subcomponent.

classmethod selected_folder(aio_id: str | Wildcard) → dict[str, Any]#

Return the ID for the selected folder store.

Parameters:
aio_idstr or _Wildcard

The component’s unique identifier.

Returns:
dict[str, Any]

The unique ID dictionary for the selected folder store subcomponent.