Skip to content

Search Bar

A search input widget with optional suggestions and filtering.

Preview

FXSearchBar

FXSearchBar

Bases: FXThemeAware, QWidget

An enhanced search input widget with built-in features.

This widget provides a search input with: - Search icon - Clear button - Optional filter dropdown - Debounced search signal for live filtering

Parameters:

Name Type Description Default

parent

Optional[QWidget]

Parent widget.

None

placeholder

str

Placeholder text.

'Search...'

debounce_ms

int

Debounce delay in milliseconds for search_changed signal.

300

show_filter

bool

Whether to show the filter dropdown.

False

filters

Optional[list]

List of filter options for the dropdown.

None
Signals

search_changed: Emitted when the search text changes (debounced). search_submitted: Emitted when Enter is pressed. filter_changed: Emitted when the filter selection changes.

Examples:

>>> search = FXSearchBar(placeholder="Search assets...")
>>> search.search_changed.connect(lambda text: print(f"Searching: {text}"))
>>> search.set_filters(["All", "Models", "Textures", "Materials"])

Methods:

Name Description
clear

Clear the search input.

setFocus

Set focus to the search input.

set_filters

Set the filter dropdown options.

set_placeholder

Set the placeholder text.

show_filter

Show or hide the filter dropdown.

Attributes:

Name Type Description
filter str

Return the current filter selection.

text str

Return the current search text.

filter property

filter: str

Return the current filter selection.

text property writable

text: str

Return the current search text.

clear

clear() -> None

Clear the search input.

setFocus

setFocus() -> None

Set focus to the search input.

set_filters

set_filters(filters: list) -> None

Set the filter dropdown options.

Parameters:

Name Type Description Default

filters

list

List of filter option strings.

required

set_placeholder

set_placeholder(text: str) -> None

Set the placeholder text.

Parameters:

Name Type Description Default

text

str

The placeholder text.

required

show_filter

show_filter(visible: bool = True) -> None

Show or hide the filter dropdown.

Parameters:

Name Type Description Default

visible

bool

Whether to show the filter dropdown.

True