Passing value to other pages

We are building a multi app, that on home we are selecting a filepath for data using tkinter filedialog, we save this path as a variable “data_path”. We want to have this data path used on the other pages.

Is there an example of how to do this, we are having no luck.

Thanks

Hello @desertwrangler,

You can use a dcc.Store to be able to send it to multiple pages.

This wouldnt be available in the initial page’s layout, but you can use it in callbacks.

Thanks, do you have an example of how to have the path on one page and use the dcc.store in the callback on another. We have been trying this but can’t seem to get it right.

The best way, is to add the dcc.Store to the layout on the app layout, and not be inside of the page_container.

Thanks again for the help.

We are able to store the path and print it on different pages. Now we are trying to read the path into a callback and add the required file name to the path. this does not seem to work with os.path.join. is there a better way to do this?

Thanks
Russ

Hello @desertwrangler,

Do you have an example of how you are trying to do this?

From Dash 2.14 you can also pass additional inputs to the multi-page routing callback so that they are available in your page layout functions. This would allow you to store those values in a dcc.Store as mentioned by @jinnyzor and then not have to have a callback that updates stuff based on that value on all your pages but rather use it directly in the layout function.

See some examples in the PR here until the docs have been updated with them :slight_smile:

1 Like

@RenaudLN,

To clarify, altering a key component would rerender the layout function?

You could choose to make it re-render or not using Input or State :slight_smile:

Ok. Interesting.

You have to declare them at the app level across the board.