Skip to content

QueryDialog

A modal dialog for collecting user input with validation.

Events

<<DialogResult>>: Fired when dialog closes. Provides event.data with keys: result (Any), confirmed (bool).

result property

result: Any

The dialog result value.

__init__

__init__(
    prompt: str,
    title: str = " ",
    value: Any = "",
    minvalue: Optional[Any] = None,
    maxvalue: Optional[Any] = None,
    width: int = 65,
    datatype: Any = str,
    padding: tuple[int, int] | int = (20, 20),
    master: Optional[Misc] = None,
    items: Optional[List[str]] = None,
    value_format: Optional[str] = None,
    increment: Optional[int | float] = None,
) -> None

Create a query dialog for collecting user input.

Parameters:

Name Type Description Default
prompt str

The prompt text to display above the input field. Supports multiline strings.

required
title str

The dialog window title.

' '
value Any

The initial value to populate in the input field.

''
value_format Optional[str]

Optional ICU format pattern for formatting/parsing values. For numbers: e.g., '$#,##0.00' for currency, '#,##0.##' for decimals For dates: e.g., 'shortDate', 'longDate', 'yyyy-MM-dd' When provided, uses specialized Field widgets (TextEntry, NumericEntry, DateEntry).

None
minvalue Optional[Any]

Minimum allowed value for numeric data types. Ignored for strings.

None
maxvalue Optional[Any]

Maximum allowed value for numeric data types. Ignored for strings.

None
increment Optional[int | float]

Step size for numeric fields (passed to NumericEntry).

None
width int

Maximum width in characters for text wrapping of the prompt.

65
datatype Any

Expected data type for validation (str, int, float, date, complex).

str
padding tuple[int, int] | int

Padding around the dialog content.

(20, 20)
master Optional[Misc]

Parent widget for the dialog.

None
items Optional[List[str]]

Optional list of items for dropdown selection. Shows a Combobox instead of Entry.

None

show

show(position: Optional[tuple[int, int]] = None) -> None

Show the dialog.

Parameters:

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

x and y coordinates to position the dialog. If None, centers on parent.

None

on_dialog_result

on_dialog_result(
    callback: Callable[[Any], None],
) -> Optional[str]

Bind a callback fired when the dialog produces a result.

The callback receives event.data["result"] when available.

Parameters:

Name Type Description Default
callback Callable[[Any], None]

Callable that receives the result payload.

required

Returns:

Type Description
Optional[str]

Binding identifier for use with off_dialog_result.

off_dialog_result

off_dialog_result(funcid: str) -> None

Unbind a previously bound dialog result callback.