Skip to content

fontlabapp.qt.dialogs · declarations 001

Back to fontlabapp.qt.dialogs

close_message_boxes

close_message_boxes(boxes: list[Any]) -> None

Close and delete every retained box, newest first; empty boxes.

Every box is tried. The first failure is re-raised at the end; a BaseException such as KeyboardInterrupt wins over an Exception.

create_message_box

create_message_box(gui: Any, text: Any, informative: Any, icon: str, parent_args: tuple[Any, ...] = (), *, detail: Any = '') -> Any

Prepare a caller-owned QMessageBox; do not show it.

icon is a QMessageBox attribute name such as "Warning". A truthy detail becomes the box's Show Details text as str(detail); a falsy one ("", None) sets none. If setup fails, the box is deleted and the error propagates. Hand the box to run_message_box (modal) or show_message_box (modeless).

name_filters

name_filters(filetypes: Sequence[str] | None) -> list[str]

Build the Qt name-filter list for a file chooser.

["ufo", ".glyphs"] gives ["Files (*.ufo *.glyphs)"]. A leading dot is optional. None or an empty sequence gives []: no filter, so the chooser shows all files. Pure function; no Qt needed.

release_closed_message_boxes

release_closed_message_boxes(boxes: list[Any]) -> None

Delete the boxes that the user closed (hidden); keep the visible ones.

Call it before showing a new box, so boxes does not grow without end.

run_button_message_box

run_button_message_box(box: Any, buttons: list[Any], accessory: Any = None) -> int | None

Borrow widgets for one modal box and return the clicked input index.

buttons are caller-owned QPushButton widgets; the return value is the index of the clicked one, or None. accessory is an optional extra widget placed under the text.

All widgets return to their original parents before box deletion, including partial configuration or execution failure. Parent lookup accepts PythonQt properties and ordinary Qt methods. Restore failure propagates before any box deletion, preserving the caller's existing fail-closed ordering. Caller owns button/default/cancel policy and recovery after native restore failure.

run_file_dialog

run_file_dialog(gui: Any, configure: Callable[[Any, Any], object], caption: Any, directory: Any, parent_args: tuple[Any, ...] = ()) -> list[str] | None

Run one owned QFileDialog; return the selected paths or None.

configure(QFileDialog, dialog) sets mode and filters (see name_filters). A falsy directory keeps the Qt default. Cancel gives None. The dialog is deleted on every exit.

run_message_box

run_message_box(box: Any, buttons: Any) -> int

Show box modally with standard buttons; return exec()'s result.

The box is deleted on every exit. Only this box runs; no other dialog.

run_owned_dialog

run_owned_dialog(dialog: Any, configure: Callable[[Any], object], read_result: Callable[[Any, Any], Any]) -> Any

Configure and execute one owned dialog, read its result, then delete it.

configure(dialog) runs first; read_result(dialog, exec_result) gives the return value. The caller supplies defaults, text conversion and acceptance/cancel policy. deleteLater runs on every exit, also when configuration, execution or result conversion fails.

run_standard_message_box

run_standard_message_box(qt: Any, parent: Any, title: Any, text: Any, icon: str, buttons: Any, default_button: Any = None) -> Any

Run an owned priority message with Qt's static standard-button result.

icon names QMessageBox.Warning/Question/etc.; title and primary text stay distinct. None keeps Qt's automatic default. Every setup/exec/result failure deletes the box through run_owned_dialog; interrupted exec is Cancel.

run_text_dialog

run_text_dialog(gui: Any, message: Any, value: Any, title: Any, ok_button: Any = None, parent_args: tuple[Any, ...] = ()) -> str | None

Run one owned QInputDialog text prompt; return the text or None.

gui is PythonQt.QtGui (injected). message is the label, value the initial text, title the window title. Falsy values become empty text. A falsy ok_button keeps the Qt default label. parent_args are positional: PythonQt constructors reject keywords. Cancel gives None and the text is not read. The dialog is deleted on every exit, also when setup, execution or the text read fails.

show_message_box

show_message_box(box: Any, boxes: list[Any], configure: Callable[[Any], object] | None = None) -> None

Show box modeless and keep it in the caller's boxes list.

The box goes into boxes first, so a failure in configure(box) or in show() still leaves it retained for close_message_boxes. A modeless box that Python does not retain could be deleted while visible.