I am playing with dash-yada. When I look through the code I see the possible actions are click, dblclick, sendKeys, type. I am trying to find a way to make yada select from a dropdown. I know the particular value will always be there. I know the value will always be the last one in the options. I thought maybe I could do a ‘type’ action with the value I want as the ‘action_args’ but I could not get that to work. Is it possible to have yada select a value from a dropdown? If so, how?
Hello @Brent,
Yes, it is possible.
You’ll need to chain together a few actions:
1 - activate the dropdown, this can be a click.
2 - then select from the dropdown, this will also be a click.
1 Like
I tried this among other things but it does not do anything.
{‘target’: f"#{CLUSTER_PREFIX}new-region-dd",
‘convo’: “”“I will activate the dropdown by clicking on it.”“”,
‘action’: ‘click’},
{‘target’: f"#{CLUSTER_PREFIX}new-region-dd .value",
‘convo’: “”“I will select new”“”,
‘action’: ‘click’,
‘action_args’: ‘new’},
If you can give an example app, that would be helpful.
1 Like
#!/usr/bin/env python3
"""Minimal dash program."""
from dash import Dash, dcc
import dash_bootstrap_components as dbc
from dash_yada import YadaAIO
app = Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
scripts = {'my_script': [{'target': '#dropdown',
'convo': """
This is a dropdown.
"""},
{'target': '#dropdown',
'convo': """
activate dropdown
""",
'action': 'click'},
{'target': '#dropdown',
'convo': """
select from dropdown
""",
'action': 'click'}
]}
yada = YadaAIO(yada_id="my_yada", scripts=scripts)
app.layout = dbc.Container([yada,
dcc.Dropdown(id='dropdown',
options=['first',
'second',
'new'],
value='first')],
fluid=True)
if __name__ == '__main__':
app.run_server(debug=True)