Skip to content

Commit

Permalink
Optimizacion en la carga del loading. Soporte para multiples versione…
Browse files Browse the repository at this point in the history
…s de streamlit. Mejoras en la posicion de la barra de navegacion.
  • Loading branch information
vquilon committed Oct 14, 2024
1 parent f058623 commit 810dd2f
Show file tree
Hide file tree
Showing 8 changed files with 363 additions and 321 deletions.
9 changes: 4 additions & 5 deletions examples/components/navbar/native_streamlit_multipage/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@

def my_sidebar():
with st.sidebar:
st.logo(
image="https://streamlit.io/images/brand/streamlit-logo-primary-colormark-darktext.svg",
icon_image="https://streamlit.io/images/brand/streamlit-mark-color.png"
)

st.write("Logged in:", st.session_state.logged_in)
position_mode = st.radio(
"Navbar position mode",
Expand Down Expand Up @@ -109,6 +104,10 @@ def logout():
)
st.session_state["app_map"] = app_map

st.logo(
image="https://streamlit.io/images/brand/streamlit-logo-primary-colormark-darktext.svg",
icon_image="https://streamlit.io/images/brand/streamlit-mark-color.png"
)
my_sidebar()

position_mode = st.session_state.get("position_mode", "top")
Expand Down
30 changes: 25 additions & 5 deletions examples/framework/multi_page.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
import streamlit as st
from streamlit_plugins.framework.multilit import MultiApp, MultiHeadApp


def run():
with st.sidebar:
position_mode = st.radio(
"Navbar position mode",
["top", "under"],
index=0 if st.session_state.get("position_mode", "top") == "top" else 1,
)
sticky_nav = st.checkbox(
"Sticky navbar", value=st.session_state.get("sticky_nav", True)
)
within_fragment = st.checkbox(
"Use within fragment", value=st.session_state.get("within_fragment", False)
)
st.divider()
st.session_state["position_mode"] = position_mode
st.session_state["sticky_nav"] = sticky_nav
st.session_state["within_fragment"] = within_fragment
# sticky_nav = False
# position_mode = "top"
# within_fragment = False
multi_app = MultiApp(
title="Demo", nav_horizontal=True, layout='wide', favicon="📚",
use_navbar=False, navbar_sticky=True, navbar_mode="top",
use_navbar=True, navbar_sticky=sticky_nav, navbar_mode=position_mode,
use_cookie_cache=True, sidebar_state='auto',
navbar_animation=True, allow_url_nav=True, hide_streamlit_markers=False, use_banner_images=None,
navbar_animation=True, allow_url_nav=False, hide_streamlit_markers=False, use_banner_images=None,
banner_spacing=None, clear_cross_app_sessions=True, session_params=None,
use_loader=False, within_fragment=True
use_loader=True, within_fragment=within_fragment
)

class Demo1App(MultiHeadApp):
def run(self):
with st.sidebar:
st.write("This is a sidebar")
st.write("This is a sidebar defined on App")

st.title("Demo 1")
_LOREM_IPSUM = [
Expand Down Expand Up @@ -54,7 +74,7 @@ def run(self):
demo1_app = Demo1App()
demo2_app = Demo2App(with_loader=False)

@multi_app.addapp(title="Home", is_home=True)
@multi_app.addapp(title="Home", app_type="home")
def my_home():
st.info('HOME')
if st.button('Demo1', key="change-app_demo1"):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
streamlit<=1.37.0
streamlit>=1.36.0

# Multilit
compress-pickle~=2.1.0
Expand Down
1 change: 0 additions & 1 deletion streamlit_plugins/components/loader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4458,7 +4458,6 @@ def stop_loader(self):
with self.loader_container:
self.display_element.empty()


def __enter__(self):
self.run_loader()

Expand Down
Loading

0 comments on commit 810dd2f

Please sign in to comment.