Skip to main content

Crate any_dialog

Crate any_dialog 

Source
Expand description

Simple desktop dialogs via whatever dialog helper the system already has: kdialog or zenity on Linux, osascript on macOS, or PowerShell on Windows. The crate links no GUI toolkit, has zero dependencies, and uses only the standard library.

Dialogs::new probes PATH for a helper, preferring the operating system’s own bundled tool on macOS and Windows, and every method on the handle renders through the helper it found. If no helper exists, calls fail with Error::NoBackend; check Dialogs::available first if that matters.

Prompt methods return Ok(None) when the user cancels, so a cancel is a value to handle, not an error:

use any_dialog::Dialogs;

fn main() -> Result<(), any_dialog::Error> {
    let dialogs = Dialogs::new();
    if let Some(name) = dialogs.prompt_text("Example", "Your name:", None)? {
        println!("hello, {name}");
    }
    Ok(())
}

Every call blocks until the user answers, so callers should run them on a worker thread rather than on a UI or event-loop thread.

Structs§

Dialogs
A handle to the best dialog backend found on this machine.
FileFilter
A named set of file extensions for a file dialog, such as “Images” over png and jpg. Extensions are bare names, without dots or wildcards; each backend decorates them into its own filter syntax. How much of the grouping survives is backend-dependent: macOS’s chooser takes one flat type list, so there the groups merge into a single extension set.
FileFilterBuilder
Builds a FileFilter from its display name, obtained from FileFilter::builder. The only way out is extensions, so a builder cannot be finished into a filter that has no extensions.

Enums§

Backend
Which helper program a crate::Dialogs handle drives.
Error
Everything that can go wrong while showing a dialog.