import inspect import textwrap import streamlit as st def show_code(demo): """Showing the code of the demo.""" show_code = st.sidebar.checkbox("Show code", True) if show_code: # Showing the code of the demo. st.markdown("## Code") sourcelines, _ = inspect.getsourcelines(demo) st.code(textwrap.dedent("".join(sourcelines[1:])))