AnnMarieW / dash-multi-page-app-demos

Minimal examples of multi-page apps using Dash Pages
221 stars 52 forks source link

Add a generic template for multi-page apps #3

Closed schwabts closed 1 year ago

schwabts commented 1 year ago

Just because I was looking for a suitable template for my applications

so I thought a collection of pages with different combinations of components would be a typical use case for a multi-page app.

AnnMarieW commented 1 year ago

Hi @schwabts

I'm not sure what you mean. This library has 18 example apps with different pages features -- and most have callbacks. Can you elaborate? Or better yet, could you do a pull request for a template that you think others would find helpful?

schwabts commented 1 year ago

@AnnMarieW right, I didn't come here by accident as the library already is the best starting point with templates for customised projects that I have been able to find so far. What I had in mind is some sort of all-in-one app and expressed by the word generic and the property of having different callbacks on the same page. I hope to be able to be more precise asap as I'm still learning using Dash.

E.g. I also like the example dash-app-structure although I did not find any page with more than one callback in it.

PS: I'll be happy to provide a PR when being able and finding the time to work something useful out.

schwabts commented 1 year ago

Hi @AnnMarieW after it had dawned on me that the point of multi-page apps would be to avoid the need for multiple callbacks on any single page I thought of a canonical use case overnight. I believe it cannot be implemented by simply distributing the callbacks over different pages.

Given a set of functions, maybe a small library, one might want to create a showcase as a multi-page app. It should contain one page per function in the library on which the user would enter a value for each parameter of the function. Depending on the types of the parameters the page would contain input fields, checkboxes, radiobuttons, and so on. Additionally a button would trigger the evaluation of the function and the display of the result.

AnnMarieW commented 1 year ago

Hi @schwabts

the point of multi-page apps would be to avoid the need for multiple callbacks on any single page

Actually, that's not true. The purpose of multi-page apps is to organize content -- to present different topics to the user on different pages.

There is no problem with having multiple callbacks on a page. You can find many examples of this in the Dash Gallery Here's the github for the open source apps: https://github.com/plotly/dash-sample-apps

Is it possible to implement this with only one callback function dispatching to different event handlers such that each parameter would not require a separate callback for changing its value?

Yes, this is possible. See the dash tutorial: https://dash.plotly.com/determining-which-callback-input-changed

Since this issue is not about a bug in this library, it would be better to move this discussion to the Dash Community forum. Others will likely find this topic helpful, plus there are a lot more people to help answer your questions.

schwabts commented 1 year ago

Thank you @AnnMarieW for the references and for contextualising them! I suppose this will be very helpful.

The purpose of multi-page apps is to organize content -- to present different topics to the user on different pages.

Ah, sure, from the user's point of view. I'd better have written of a side-effect from the developer's point of view.