Skip to content

FilterDialog

Bases: Frame

A dialog for filtering and selecting multiple items from a list.

This dialog displays a list of checkboxes with optional search and select-all functionality. When the user clicks OK, the selected values are stored in the result property.

Events

<<SelectionChange>>: Triggered when OK is clicked and selections are confirmed. Provides event.data with key: selected (list[Any]).

Attributes:

Name Type Description
result list[Any] | None

List of selected values after dialog is closed, or None if canceled.

__init__

__init__(
    master: Master = None,
    title: str = "Filter",
    items: list[str | dict[str, Any]] = None,
    enable_search: bool = False,
    enable_select_all: bool = False,
    frameless: bool = False,
)

Initialize the FilterDialog.

Parameters:

Name Type Description Default
master Master

Parent widget. If None, uses the default root window.

None
title str

Dialog window title.

'Filter'
items list[str | dict[str, Any]]

List of items to display. Can be strings or dicts with keys: - text (str): Display text (required for dict items) - value (Any): Value to return when selected (defaults to text) - selected (bool): Initial selection state (defaults to False)

None
enable_search bool

If True, includes a search box to filter items by text.

False
enable_select_all bool

If True, includes a "Select All" checkbox.

False
frameless bool

If True, removes window decorations and displays with a border frame. Enables dismiss-on-outside-click behavior.

False

on_selection_changed

on_selection_changed(callback: Callable) -> str

Bind to <<SelectionChange>>. Callback receives event.data = {"selected": list[Any]}.

Returns:

Type Description
str

Binding identifier for use with off_selection_changed().

off_selection_changed

off_selection_changed(bind_id: str = None)

Unbind callback from <> event.

Parameters:

Name Type Description Default
bind_id str

Binding identifier from on_selection_changed().

None

show

show(
    position: Optional[Tuple[int, int]] = None,
    modal: Optional[bool] = None,
    *,
    anchor_to: Optional[
        Union[Widget, Literal["screen", "cursor", "parent"]]
    ] = None,
    anchor_point: AnchorPoint = "center",
    window_point: AnchorPoint = "center",
    offset: Tuple[int, int] = (0, 0),
    auto_flip: Union[
        bool, Literal["vertical", "horizontal"]
    ] = False,
) -> Optional[list[Any]]

Show the dialog and return the selected items.

Parameters:

Name Type Description Default
position Optional[Tuple[int, int]]

Optional (x, y) coordinates to position the dialog. If provided, takes precedence over anchor-based positioning.

None
modal Optional[bool]

Override the mode's default modality. If None, uses True (modal mode).

None
anchor_to Optional[Union[Widget, Literal['screen', 'cursor', 'parent']]]

Positioning target. Can be: - Widget: Anchor to a specific widget - "screen": Anchor to screen edges/corners - "cursor": Anchor to mouse cursor location - "parent": Anchor to parent window (same as widget) - None: Centers on parent (default)

None
anchor_point AnchorPoint

Point on the anchor target (n, s, e, w, ne, nw, se, sw, center). Default 'center'.

'center'
window_point AnchorPoint

Point on the dialog window (n, s, e, w, ne, nw, se, sw, center). Default 'center'.

'center'
offset Tuple[int, int]

Additional (x, y) offset in pixels from the anchor position.

(0, 0)
auto_flip Union[bool, Literal['vertical', 'horizontal']]

Smart positioning to keep window on screen. - False: No flipping (default) - True: Flip both vertically and horizontally as needed - 'vertical': Only flip up/down - 'horizontal': Only flip left/right

False

Returns:

Type Description
Optional[list[Any]]

List of selected item values, or None if canceled.