Skip to content

Commit

Permalink
readme images
Browse files Browse the repository at this point in the history
  • Loading branch information
e3rd committed Jul 25, 2024
1 parent 7066b00 commit f246492
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
29 changes: 22 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

Write the program core, do not bother with the input/output.

![hello world example](asset/hello-world.png "A minimal use case")
![Hello world example: GUI window](asset/hello-world.png "A minimal use case – GUI")
![Hello world example: TUI fallback](asset/hello-tui.webp "A minimal use case – TUI fallback")

Check out the code that displays such window, just the code you need. No lengthy blocks of code imposed by an external dependency.
Check out the code that displays such window or its textual fallback.

```python
from dataclasses import dataclass
Expand All @@ -25,24 +26,38 @@ if __name__ == "__main__":
print(args.important_number) # suggested by the IDE with the hint text "This number is very important"
```

Or bound the interface to a `with` statement that redirects stdout directly to the window.
It's all the code you need. No lengthy blocks of code imposed by an external dependency. Besides the GUI/TUI, you receive powerful YAML-configurable CLI parsing.

```bash
$ ./hello.py
usage: My application [-h] [--test | --no-test] [--important-number INT]

Set of options.

╭─ options ──────────────────────────────────────────────────────────╮
│ -h, --help show this help message and exit
│ --test, --no-test My testing flag (default: False) │
│ --important-number INT This number is very important (default: 4) │
╰────────────────────────────────────────────────────────────────────╯
```

You get several useful methods to handle user dialogues. Here we bound the interface to a `with` statement that redirects stdout directly to the window.

```python
with run(Config) as m:
print(f"Your important number is {m}")
boolean = m.is_yes("Is that alright?")
```

TODO img
![Small window with the text 'Your important number'](asset/hello-with-statement.webp "With statement to redirect the output")
![The same in terminal'](asset/hello-with-statement-tui.webp "With statement in TUI fallback")

Loading config file is a piece of cake. Alongside `program.py`, put `program.yaml`. Instantly loaded.
Loading config file is a piece of cake. Alongside `program.py`, put `program.yaml` and put there some of the arguments. Instantly loaded.

```yaml
important_number: 555
```
TODO img
- [Mininterface – GUI, TUI, CLI and config](#mininterface-gui-tui-cli-and-config)
- [Background](#background)
- [Installation](#installation)
Expand Down
Binary file added asset/hello-tui.webp
Binary file not shown.
Binary file added asset/hello-with-statement-tui.webp
Binary file not shown.
Binary file added asset/hello-with-statement.webp
Binary file not shown.
2 changes: 2 additions & 0 deletions mininterface/TextualInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
from .FormField import FormField
from .Mininterface import Cancelled

# TODO with statement hello world example image is wrong – Textual still does not redirect the output as GuiInterface does

@dataclass
class DummyWrapper:
""" Value wrapped, since I do not know how to get it from textual app.
Expand Down

0 comments on commit f246492

Please sign in to comment.