bootstack.dialogs.FormDialog#

class bootstack.dialogs.FormDialog(*, title='Form', data=None, items=None, col_count=1, min_col_width=None, on_data_change=None, on_close=None, width=None, height=None, buttons=None, min_size=None, max_size=None, resizable=False, parent=None)#

Bases: object

A dialog window that embeds a Form for structured data entry.

Parameters:
  • title (str) – Dialog window title.

  • data (dict[str, Any] | None) – Initial data backing the form. Keys become field names.

  • items (Sequence[Any] | None) – Explicit form layout — FormItem / GroupItem / TabsItem instances or equivalent dicts. If omitted, fields are inferred from data.

  • col_count (int) – Number of form columns. Default 1.

  • min_col_width (int | None) – Minimum column width in pixels.

  • on_data_change (Callable[[dict[str, Any]], Any] | None) – Callback invoked on every field change, receiving the current data dict.

  • on_close (Callable[[], Any] | None) – Callback fired when the dialog closes by any means.

  • width (int | None) – Explicit form width in pixels.

  • height (int | None) – Explicit form height in pixels.

  • buttons (Iterable[ButtonSpec | str] | None) – Footer button specs. Defaults to Cancel + OK.

  • min_size (tuple[int, int] | None) – Minimum dialog window size (width, height).

  • max_size (tuple[int, int] | None) – Maximum dialog window size (width, height).

  • resizable (tuple[bool, bool] | bool) – Allow window resizing. Default False.

  • parent (Any) – Parent widget. Defaults to the active root window.

property form: Any#

The embedded Form widget — for advanced programmatic access.

property result: dict[str, Any] | None#

Form data dict after closing, or None if canceled.

show(*, position=None, modal=None)#

Display the dialog and block until it is closed.

Parameters:
  • position (tuple[int, int] | None) – Explicit (x, y) screen coordinates for the dialog. Defaults to centered on the parent window.

  • modal (bool | None) – Override the default modality. True blocks the parent; False shows a non-blocking dialog.

Returns:

self — allows chaining – dlg = FormDialog(...).show(); dlg.result.

Return type:

FormDialog