Skip to content

Commit

Permalink
Merge pull request #100 from blackary/support-1.36
Browse files Browse the repository at this point in the history
  • Loading branch information
blackary authored Jun 25, 2024
2 parents 2b34cad + ad04abb commit 1afb267
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion example_app/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
st_pages>=0.4.3
streamlit>=1.25.0
-e .
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "st-pages"
version = "0.4.5"
version = "0.5.0"
license = "MIT"
description = "An experimental version of Streamlit Multi-Page Apps"
authors = ["Zachary Blackwood <zachary@streamlit.io>"]
Expand Down
21 changes: 16 additions & 5 deletions src/st_pages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from time import sleep

import toml
from packaging.version import Version

try:
from streamlit import _gather_metrics # type: ignore
Expand Down Expand Up @@ -249,10 +250,13 @@ def _show_pages(pages: list[Page]):
if hasattr(rt, "_script_cache"):
sleep(1) # Not sure why this is needed, but it seems to be.

rt._sources_watcher = LocalSourcesWatcher(rt._main_script_path)
rt._sources_watcher.register_file_change_callback(
lambda _: rt._script_cache.clear()
)
try:
rt._sources_watcher = LocalSourcesWatcher(rt._main_script_path)
rt._sources_watcher.register_file_change_callback(
lambda _: rt._script_cache.clear()
)
except AttributeError:
pass


show_pages = _gather_metrics("st_pages.show_pages", _show_pages)
Expand Down Expand Up @@ -331,9 +335,16 @@ def _get_indentation_code() -> str:
is_indented = False
elif is_indented:
# Unless specifically unnested, indent all pages that aren't section headers
# Tweak the styling for streamlit >= 1.36.0
st_version_string = st.__version__

extra_selector = "span:nth-child(1)"
if Version(st_version_string) >= Version("1.36.0"):
extra_selector = "a > span:first-child"

styling += f"""
div[data-testid=\"stSidebarNav\"] li:nth-child({idx + 1})
span:nth-child(1) {{
{extra_selector} {{
margin-left: 1.5rem;
}}
"""
Expand Down
14 changes: 7 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[tox]
envlist = py{38,39,310}-streamlit{21,23,25,27}
envlist = py{39,310,311}-streamlit{24,28,32,36}
isolated_build = True

[testenv]
deps =
pytest
pytest-playwright
pytest-rerunfailures
streamlit21: streamlit==1.21.0
streamlit23: streamlit==1.23.0
streamlit25: streamlit==1.25.0
streamlit27: streamlit==1.27.0
streamlit24: streamlit==1.24.0
streamlit28: streamlit==1.28.0
streamlit32: streamlit==1.32.0
streamlit36: streamlit==1.36.0

commands:
playwright install
Expand All @@ -24,6 +24,6 @@ basepython = python3

[gh-actions]
python =
3.8: py38
3.9: py39
3.10: py310
3.10: py310
3.11: py311

0 comments on commit 1afb267

Please sign in to comment.