I started checking Dash (in Julia) today and got the following error
ERROR: The arguments of the specified callback function do not align with the currently defined callback; please ensure that the arguments to func
are properly defined.
This is my code:
using Dash
app = dash()
app.layout = html_div() do
html_h2("Change the value in the text box to change the font size of the text below!",
style = Dict("textAlign" => "center")),
html_div(
children = [
"Font size: ",
dcc_input(id = "input-font-size-1", value = "1em", type = "text")
],
),
html_br(),
html_div("Is the font size changing?", id = "my-output-1"),
dcc_radioitems(
id = "my-radioitems-1",
options = [
Dict("label" => "Yes", "value" => "yes"),
Dict("label" => "No", "value" => "no"),
],
value = "",
),
html_div(id = "my-output-2")
end
callback!(app, Output("my-output-1", "style"), Input("input-font-size-1", "value")) do input_value
Dict("fontSize" => input_value)
end
callback!(app, Output("my-radioitems-1", "style"), Input("input-font-size-1", "value")) do input_value
Dict("fontSize" => input_value)
end
callback!(app, Output("my-output-2", "children"), Input("my-radioitems-1", "value")) do input_value
if input_value == "yes"
"I know, Iknow. It's changing!"
elseif input_value == "no"
"You liar!"
else
"Please select an option."
end
end
callback!(app, Output("my-output-2", "style"), [Input("input-font-size-1", "value"), Input("my-radioitems-1", "value")]) do input_values
font_size, radio_value = input_values
text_color = "black"
if radio_value == "yes"
text_color = "green"
elseif radio_value == "no"
text_color = "red"
end
Dict("fontSize" => font_size, "color" => text_color)
end
run_server(app, "0.0.0.0", debug=true)
Any help is welcome. Thank you!