Skip to content

Commit 1afb267

Browse files
authored
Merge pull request #100 from blackary/support-1.36
2 parents 2b34cad + ad04abb commit 1afb267

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

example_app/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
st_pages>=0.4.3
21
streamlit>=1.25.0
2+
-e .

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "st-pages"
3-
version = "0.4.5"
3+
version = "0.5.0"
44
license = "MIT"
55
description = "An experimental version of Streamlit Multi-Page Apps"
66
authors = ["Zachary Blackwood <zachary@streamlit.io>"]

src/st_pages/__init__.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from time import sleep
77

88
import toml
9+
from packaging.version import Version
910

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

252-
rt._sources_watcher = LocalSourcesWatcher(rt._main_script_path)
253-
rt._sources_watcher.register_file_change_callback(
254-
lambda _: rt._script_cache.clear()
255-
)
253+
try:
254+
rt._sources_watcher = LocalSourcesWatcher(rt._main_script_path)
255+
rt._sources_watcher.register_file_change_callback(
256+
lambda _: rt._script_cache.clear()
257+
)
258+
except AttributeError:
259+
pass
256260

257261

258262
show_pages = _gather_metrics("st_pages.show_pages", _show_pages)
@@ -331,9 +335,16 @@ def _get_indentation_code() -> str:
331335
is_indented = False
332336
elif is_indented:
333337
# Unless specifically unnested, indent all pages that aren't section headers
338+
# Tweak the styling for streamlit >= 1.36.0
339+
st_version_string = st.__version__
340+
341+
extra_selector = "span:nth-child(1)"
342+
if Version(st_version_string) >= Version("1.36.0"):
343+
extra_selector = "a > span:first-child"
344+
334345
styling += f"""
335346
div[data-testid=\"stSidebarNav\"] li:nth-child({idx + 1})
336-
span:nth-child(1) {{
347+
{extra_selector} {{
337348
margin-left: 1.5rem;
338349
}}
339350
"""

tox.ini

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
[tox]
2-
envlist = py{38,39,310}-streamlit{21,23,25,27}
2+
envlist = py{39,310,311}-streamlit{24,28,32,36}
33
isolated_build = True
44

55
[testenv]
66
deps =
77
pytest
88
pytest-playwright
99
pytest-rerunfailures
10-
streamlit21: streamlit==1.21.0
11-
streamlit23: streamlit==1.23.0
12-
streamlit25: streamlit==1.25.0
13-
streamlit27: streamlit==1.27.0
10+
streamlit24: streamlit==1.24.0
11+
streamlit28: streamlit==1.28.0
12+
streamlit32: streamlit==1.32.0
13+
streamlit36: streamlit==1.36.0
1414

1515
commands:
1616
playwright install
@@ -24,6 +24,6 @@ basepython = python3
2424

2525
[gh-actions]
2626
python =
27-
3.8: py38
2827
3.9: py39
29-
3.10: py310
28+
3.10: py310
29+
3.11: py311

0 commit comments

Comments
 (0)