From ece5d0416578278af6223f5956ffa0928ecff0da Mon Sep 17 00:00:00 2001 From: Edvard Rejthar Date: Tue, 22 Oct 2024 17:53:41 +0200 Subject: [PATCH] textual button submits the form --- mininterface/textual_interface/textual_app.py | 2 +- mininterface/textual_interface/widgets.py | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/mininterface/textual_interface/textual_app.py b/mininterface/textual_interface/textual_app.py index 643d62a..d95121c 100644 --- a/mininterface/textual_interface/textual_app.py +++ b/mininterface/textual_interface/textual_app.py @@ -66,7 +66,7 @@ def widgetize(tag: Tag) -> Widget | Changeable: # Replace with a callback button elif tag._is_a_callable(): - o = MyButton(tag.name, val=tag.val) + o = MyButton(tag.name) else: if not isinstance(v, (float, int, str, bool)): diff --git a/mininterface/textual_interface/widgets.py b/mininterface/textual_interface/widgets.py index 33ed29b..faebe3a 100644 --- a/mininterface/textual_interface/widgets.py +++ b/mininterface/textual_interface/widgets.py @@ -52,15 +52,12 @@ def on_key(self, event: events.Key) -> None: class MyButton(Button, Changeable): _val: TagValue - def __init__(self, *args, val=False, **kwargs): - super().__init__(*args, **kwargs) - self._val = val - def on_button_pressed(self, event): - return self._link.val() + self._link.facet.submit() + self._link.val() def get_ui_value(self): - return self._val + return self._link.val class MySubmitButton(MyButton):