Is there any way to refactor large apps it into functions?

Summary

An app I’m building is getting very big/long. Think 2000+ lines of mostly Streamlit code.

This is because I have some widgets, some graphs, some tabs, columns, metrics… etc.

I would like to refactor this into smaller files to manage the complexity - but I don’t know what is Streamlit’s best practice for this.

Maybe my code should look like this:

from helpers import render_widgets, render_data, render_charts, rernder_metrics

filters =  render_widgets()
selected_data = render_data(filters)
charts = render_charts(selected_data, filters)
rernder_metrics(charts, selected_data, filters)

But in this case the render_widgets function (for example) would be generating multiple columns of widgets of various kinds… etc.

To clarify, this is still a single page app.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.