# dialogs

Windows message boxes, yes/no questions, and open / save / folder pickers. Windows only.

```
basher install dialogs
```

```python
import dialogs

if dialogs.ask("Delete the old saves?"):
    folder = dialogs.pick_folder("Where are they?")
    ...
dialogs.info("Done.")
```

## Functions

| function | shows |
|---|---|
| `message(text, title="Basher")` | a plain box with OK |
| `info(text, title=...)`, `warning(...)`, `error(...)` | the same with the info / warning / error icon |
| `ask(text, title=...) -> bool` | Yes / No. Closing it with the X counts as No |
| `ask_cancel(text, title=...) -> int` | Yes / No / Cancel: `dialogs.YES` (1), `dialogs.NO` (0), `dialogs.CANCEL` (-1) |
| `open_file(title="Open", filter="All files\|*.*", start="") -> str` | pick an existing file; `""` if cancelled |
| `save_file(title="Save as", filter=..., start="") -> str` | pick where to save; asks before overwriting; `""` if cancelled |
| `pick_folder(title="Pick a folder") -> str` | pick a folder; `""` if cancelled |

`filter` is pairs of `name|patterns`, joined by `|`: `"Images|*.png;*.jpg|All files|*.*"`. `start` is the folder the
picker opens in. Boxes open in front of everything (a console program's box would otherwise hide behind the console).
Every call waits until the person answers.

## Testing a program that uses it

Don't click through it by hand: run it headless with the `horseman` library (Headless Horseman), which starts it on
a hidden desktop and presses the buttons from code. See `../horseman/README.md`.

## Example

`examples/hello.bsh`: an info box, a question, a file picker, a save picker.
