Dash Startup ... with parameters

I have a Dash app that works well.

The navbar has 6 buttons to drive different views of the data.

How can i set it up so that i can provide a link to someone such that it loads the web app and ‘clicks one of the butons’
eg… i want to be able to send something like “www.myapp.com/button-1

thanks
c

Checkout URL support here. You will need to write a callback that handles the desired page layout when the user navigates to www.myapp.com/button-1

many thanks. i managed to hack it up this morning using dcc.Location and ripping the query string … like this:

@app.callback([Output(‘search_text’, ‘value’),
Output(‘search_text’,‘n_submit’)],
[Input(‘url’, ‘pathname’),
Input(‘url’, ‘search’)
])

def display_page(pathname ,search):
if pathname == “/search”:
return search.replace(’?’,’’), -1
raise PreventUpdate

So now when the link is “www.myapp.com/search?London” … the above code will will set my [search_text.value] to be ‘London’ … not so hard …

The real issue i was having was getting it to “trigger” my fairly complex event that lies behind the search. Since its one of those multi-input event ‘funnels’ (user might have clicked and of n buttons, plus lots of state inputs etc) that everyone has to use to work around the “single output per component value” thing … (below)

@app.callback([
Output(‘q-ids’, ‘children’),
Output(‘question_header’, ‘children’)
],
[
Input(‘entity_selected’, ‘children’),
Input(‘search_text’,‘n_submit’),
Input(‘map_questions’,‘children’),
Input(‘polar_button_group’,‘children’),
Input(‘questions_curated_selected’,‘children’),
#Input(‘auto_topic_filter’,‘value’),
],
[
State(‘search_text’,‘value’)
])

that means that inside the callback event i have to use Context to work out what has really triggered the callback …

ctx = dash.callback_context.triggered[0]

followed by lots of if . .else …

BUT that ctx is of course missing when you serve up the whole page from scratch.

So i had to write some logic to drive the special case of no Context …

p.s. sorry for the code formatting … i replied mia email

If the code is setting search_text.value correctly, why not use this as an Input to your other callback - i suspect the callback will be triggered initially on app load, then again when search_text.value is set.

I set it to be state because otherwise it triggers for each character being typed in the box (it’s also a gui element, of type input) ie. when being used normally I want someone to finish their text, then hit return which fires the n_clicks as the input value.

If you want somebody to finish entering text then press enter before callback is triggered, then setting debounce=True should do the trick. Or did you want the input box to be dual purposed for searching as the user entered text…in that case your implementation is good.

Interesting, never saw debounce before. Thanks!!

But yes, this was a late requirement added long after. Originally the site was a pure starting point but now they want different entry points as it were.

Btw, if you have a second you can check it out at

Fatinger.pythonanywhere.com, from a desktop…