Open stripuramallu3 opened 8 months ago
Hi,
You should be able to update the values
attribute on your RadioList
instance, as shown in the example below. The radio options change when the c key is pressed.
from prompt_toolkit.application import Application, get_app
from prompt_toolkit.layout.layout import Layout
from prompt_toolkit.widgets import RadioList
from prompt_toolkit.key_binding import KeyBindings
radios = RadioList([(0, "a"), (1, "b"), (2, "c")])
kb = KeyBindings()
@kb.add("q")
def _quit(event):
get_app().exit()
@kb.add("c")
def _change(even):
radios.values = [(0, "x"), (1, "y"), (2, "z")]
Application(layout=Layout(radios), key_bindings=kb).run()
You could access the RadioList
's key-bindings with radios.control.key_bindings
and add they key-binding there.
I was wondering if its possible to dynamically update the items in a RadioList.
I've figured out how to update the data inside of a TextArea, and would like to do something similar with the RadioList:
I've tried updating the RadioList's
values
andcurrent_values
but that didn't work: