diff --git a/README.md b/README.md index 4f19464..9eb9393 100644 --- a/README.md +++ b/README.md @@ -52,12 +52,12 @@ Check out several useful methods to handle user dialogues. Here we bound the int ```python with run(Env) as m: - print(f"Your important number is {m}") + print(f"Your important number is {m.env.important_number}") boolean = m.is_yes("Is that alright?") ``` ![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") +![The same in terminal'](asset/hello-with-statement-tui.avif "With statement in TUI fallback") # Contents - [Mininterface – GUI, TUI, CLI and config](#mininterface-gui-tui-cli-and-config) @@ -95,7 +95,7 @@ The config variables needed by your program are kept in cozy dataclasses. Write Install with a single command from [PyPi](https://pypi.org/project/mininterface/). -```python3 +```bash pip install mininterface ``` diff --git a/asset/hello-with-statement-tui.avif b/asset/hello-with-statement-tui.avif new file mode 100644 index 0000000..b27d9a2 Binary files /dev/null and b/asset/hello-with-statement-tui.avif differ diff --git a/asset/hello-with-statement-tui.webp b/asset/hello-with-statement-tui.webp deleted file mode 100644 index bc3dc3c..0000000 Binary files a/asset/hello-with-statement-tui.webp and /dev/null differ diff --git a/mininterface/GuiInterface.py b/mininterface/GuiInterface.py index bc946e7..aba53b3 100644 --- a/mininterface/GuiInterface.py +++ b/mininterface/GuiInterface.py @@ -128,9 +128,11 @@ def buttons(self, text: str, buttons: list[tuple[str, Any]], focused: int = 1): label = Label(self.frame, text=text) label.pack(pady=10) - for text, value in buttons: + for i, (text, value) in enumerate(buttons): button = Button(self.frame, text=text, command=lambda v=value: self._ok(v)) - button.bind("", lambda _: button.invoke()) + if i == focused-1: + b = button + button.bind("", lambda _: b.invoke()) button.pack(side=LEFT, padx=10) self.frame.winfo_children()[focused].focus_set() return self.mainloop() diff --git a/mininterface/TextualInterface.py b/mininterface/TextualInterface.py index a6e9eb8..b34fc36 100644 --- a/mininterface/TextualInterface.py +++ b/mininterface/TextualInterface.py @@ -20,9 +20,6 @@ from .Redirectable import Redirectable from .TextInterface import TextInterface -# TODO with statement hello world example image is wrong (Textual already redirects the output as GuiInterface does) - - @dataclass class DummyWrapper: """ Value wrapped, since I do not know how to get it from textual app. diff --git a/pyproject.toml b/pyproject.toml index ad75102..d06662d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "mininterface" -version = "0.4.4rc3" +version = "0.4.4rc4" description = "A minimal access to GUI, TUI, CLI and config" authors = ["Edvard Rejthar "] license = "GPL-3.0-or-later"