Skip to content

Commit

Permalink
textual button submits the form
Browse files Browse the repository at this point in the history
  • Loading branch information
e3rd committed Oct 22, 2024
1 parent 1a1cf1f commit ece5d04
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion mininterface/textual_interface/textual_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down
9 changes: 3 additions & 6 deletions mininterface/textual_interface/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit ece5d04

Please sign in to comment.