On the Streamlit documentation, explain how to create a global filter widget that maintains its state across different pages in a Streamlit app. Describe the recommended app structure for this, the method for making the widget stateful, and any important limitations or considerations.
Navigate to 'docs.streamlit.io'. Locate the documentation section related to 'Multipage apps' and 'Working with widgets'. Identify the preferred method for structuring multipage apps to support persistent global widgets. Determine the specific strategy for defining a widget to ensure its state persists across pages. Note any caveats or limitations associated with the recommended approach. Synthesize the information on app structure, widget persistence, and caveats into a concise explanation.
State that the preferred method for structuring multipage apps is using `st.Page` and `st.navigation`. Explain that the entrypoint file acts as a 'router' or 'picture frame' when using `st.Page` and `st.navigation`. State that the preferred strategy for a global filter to persist its state is to define the widget (e.g., `st.selectbox`) in the entrypoint file. Confirm that this approach does not work if the app is defined using the `pages/` directory method.