Skip to content

textual_fspicker.path_filters

Code to handle the filters for the dialogs.

FilterFunction module-attribute

FilterFunction = Callable[[Path], bool]

Type of a path filter function.

Filter

Bases: NamedTuple

A path filter.

name instance-attribute

name

The name of the filter.

This is the text that will be presented to the user in the filtering dropdown widget inside any dialog

tester instance-attribute

tester

The test function for the filter.

This is the function that will be called to test of a particular Path passes the filter.

__call__

__call__(path)

Test the given path to see if it passes the filter.

Parameters:

Name Type Description Default

path

Path

The Path to test.

required

Returns:

Type Description
bool

True if the Path passes the filter condition, False if not.

Filters

Filters(*filters)

A path filter collection.

Parameters:

Name Type Description Default

filters

Filter | tuple[str, FilterFunction]

The initial set of filters.

()

selections property

selections

The filters in a Select-friendly form.

__bool__

__bool__()

Are there any filters?

Returns:

Type Description
bool

True if there are any filters in the filer collection, False if not.

__getitem__

__getitem__(filter_id)

Get a filter given its numeric ID.

Parameters:

Name Type Description Default

filter_id

int

The numeric ID for the filter.

required

Returns:

Type Description
Filter

The filter with that ID.

This is intended to be used in conjunction with selections; where the return value for that will include a numeric ID for each filter that can be used with a Textual Select widget.