st-pages


Namest-pages JSON
Version 1.0.1 PyPI version JSON
download
home_pageNone
SummaryAn experimental version of Streamlit Multi-Page Apps
upload_time2024-08-08 19:58:58
maintainerNone
docs_urlNone
authorZachary Blackwood
requires_python!=2.7.*,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*,!=3.8.*,>=3.9
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Streamlit-Pages

[![Releases](https://img.shields.io/pypi/v/st-pages)](https://pypi.org/project/st-pages/)
[![Build Status](https://img.shields.io/github/actions/workflow/status/blackary/st_pages/testing.yml?branch=main)](https://github.com/blackary/st_pages/actions?query=workflow%3A%22testing%22+branch%3Amain)
![Python Versions](https://img.shields.io/pypi/pyversions/st_pages.svg)
![Streamlit versions](https://img.shields.io/badge/streamlit-1.36.0-white.svg)
![License](https://img.shields.io/github/license/blackary/st_pages)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

[![Streamlit App](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://st-pages.streamlit.app)

Author: [@blackary](https://github.com/blackary)

Code: https://github.com/blackary/st_pages

## Installation

```sh
pip install st-pages
```

## See it in action

Basic example: https://st-pages.streamlit.app/

Example with sections: https://st-pages-sections.streamlit.app/

## Why st-pages?

Previously, st-pages allowed for a much more customizable and flexible declaration of
pages in a Streamlit app, and was independent of the actual filenames of the python
files in your project.

As of 1.0.0, st-pages is now a tiny wrapper that provides an easy method for defining
the pages in your app in a toml file, as well as a few utility methods to let you
add the current page's title to all pages, etc.

You are welcome to continue to use older versions of this package, but most of the
old use-cases are now easy to do with native streamlit, so I would recommend
checking out the [documentation](https://docs.streamlit.io/develop/concepts/multipage-apps/page-and-navigation)
for more information.

## How to use

### Declare pages inside of a toml file

Contents of `.streamlit/pages.toml`

```toml
[[pages]]
path = "page1.py"
name = "Home"
icon = "🏠"

[[pages]]
path = "other_pages/page2.py"
name = "Page 2"
icon = ":books:"
url_path = "my_books" # You can override the default url path for a page
```

Example with sections, `.stremalit/pages_sections.toml`:

```toml
[[pages]]
path = "page1.py"
name = "Home"
icon = "🏠"

[[pages]]
path = "other_pages/page2.py"
name = "Page 2"
icon = ":books:"

[[pages]]
name = "My section"
icon = "🎈️"
is_section = true

# Pages after an `is_section = true` will be indented
[[pages]]
name = "Another page"
icon = "💪"
```

Streamlit code:

```python
import streamlit as st
from st_pages import add_page_title, get_nav_from_toml

st.set_page_config(layout="wide")

# If you want to use the no-sections version, this
# defaults to looking in .streamlit/pages.toml, so you can
# just call `get_nav_from_toml()`
nav = get_nav_from_toml(".streamlit/pages_sections.toml")

st.logo("logo.png")

pg = st.navigation(nav)

add_page_title(pg)

pg.run()
```

# Hiding pages

You can now pass a list of page names to `hide_pages` to hide pages from now on.

This list of pages is custom to each viewer of the app, so you can hide pages
from one viewer but not from another using this method. You can see another example of
hiding pages in the docs [here](https://docs.streamlit.io/develop/tutorials/multipage/dynamic-navigation)

```py
from st_pages import hide_pages

hide_pages(["Another page"])
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "st-pages",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "!=2.7.*,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*,!=3.8.*,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Zachary Blackwood",
    "author_email": "zachary@streamlit.io",
    "download_url": "https://files.pythonhosted.org/packages/83/60/f9516698fc3952bba1d1b6c1cb0795aa82dac12473f5fb678066532268e0/st_pages-1.0.1.tar.gz",
    "platform": null,
    "description": "# Streamlit-Pages\n\n[![Releases](https://img.shields.io/pypi/v/st-pages)](https://pypi.org/project/st-pages/)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/blackary/st_pages/testing.yml?branch=main)](https://github.com/blackary/st_pages/actions?query=workflow%3A%22testing%22+branch%3Amain)\n![Python Versions](https://img.shields.io/pypi/pyversions/st_pages.svg)\n![Streamlit versions](https://img.shields.io/badge/streamlit-1.36.0-white.svg)\n![License](https://img.shields.io/github/license/blackary/st_pages)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n\n[![Streamlit App](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://st-pages.streamlit.app)\n\nAuthor: [@blackary](https://github.com/blackary)\n\nCode: https://github.com/blackary/st_pages\n\n## Installation\n\n```sh\npip install st-pages\n```\n\n## See it in action\n\nBasic example: https://st-pages.streamlit.app/\n\nExample with sections: https://st-pages-sections.streamlit.app/\n\n## Why st-pages?\n\nPreviously, st-pages allowed for a much more customizable and flexible declaration of\npages in a Streamlit app, and was independent of the actual filenames of the python\nfiles in your project.\n\nAs of 1.0.0, st-pages is now a tiny wrapper that provides an easy method for defining\nthe pages in your app in a toml file, as well as a few utility methods to let you\nadd the current page's title to all pages, etc.\n\nYou are welcome to continue to use older versions of this package, but most of the\nold use-cases are now easy to do with native streamlit, so I would recommend\nchecking out the [documentation](https://docs.streamlit.io/develop/concepts/multipage-apps/page-and-navigation)\nfor more information.\n\n## How to use\n\n### Declare pages inside of a toml file\n\nContents of `.streamlit/pages.toml`\n\n```toml\n[[pages]]\npath = \"page1.py\"\nname = \"Home\"\nicon = \"\ud83c\udfe0\"\n\n[[pages]]\npath = \"other_pages/page2.py\"\nname = \"Page 2\"\nicon = \":books:\"\nurl_path = \"my_books\" # You can override the default url path for a page\n```\n\nExample with sections, `.stremalit/pages_sections.toml`:\n\n```toml\n[[pages]]\npath = \"page1.py\"\nname = \"Home\"\nicon = \"\ud83c\udfe0\"\n\n[[pages]]\npath = \"other_pages/page2.py\"\nname = \"Page 2\"\nicon = \":books:\"\n\n[[pages]]\nname = \"My section\"\nicon = \"\ud83c\udf88\ufe0f\"\nis_section = true\n\n# Pages after an `is_section = true` will be indented\n[[pages]]\nname = \"Another page\"\nicon = \"\ud83d\udcaa\"\n```\n\nStreamlit code:\n\n```python\nimport streamlit as st\nfrom st_pages import add_page_title, get_nav_from_toml\n\nst.set_page_config(layout=\"wide\")\n\n# If you want to use the no-sections version, this\n# defaults to looking in .streamlit/pages.toml, so you can\n# just call `get_nav_from_toml()`\nnav = get_nav_from_toml(\".streamlit/pages_sections.toml\")\n\nst.logo(\"logo.png\")\n\npg = st.navigation(nav)\n\nadd_page_title(pg)\n\npg.run()\n```\n\n# Hiding pages\n\nYou can now pass a list of page names to `hide_pages` to hide pages from now on.\n\nThis list of pages is custom to each viewer of the app, so you can hide pages\nfrom one viewer but not from another using this method. You can see another example of\nhiding pages in the docs [here](https://docs.streamlit.io/develop/tutorials/multipage/dynamic-navigation)\n\n```py\nfrom st_pages import hide_pages\n\nhide_pages([\"Another page\"])\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "An experimental version of Streamlit Multi-Page Apps",
    "version": "1.0.1",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a70477c5f0cdc21deb6eadd77bdbf88157632178865e71adffed728fa9e5b48b",
                "md5": "8c04252a1808fa355e440bff8b30393d",
                "sha256": "9098fb4d96bc1dfa56cc2c56ef6fe44e607c69261ff4bceee1f6e9c1e0c2acb4"
            },
            "downloads": -1,
            "filename": "st_pages-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8c04252a1808fa355e440bff8b30393d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "!=2.7.*,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*,!=3.8.*,>=3.9",
            "size": 20099,
            "upload_time": "2024-08-08T19:58:56",
            "upload_time_iso_8601": "2024-08-08T19:58:56.991128Z",
            "url": "https://files.pythonhosted.org/packages/a7/04/77c5f0cdc21deb6eadd77bdbf88157632178865e71adffed728fa9e5b48b/st_pages-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8360f9516698fc3952bba1d1b6c1cb0795aa82dac12473f5fb678066532268e0",
                "md5": "ff0bfb50d39c60da846907d3d7a6fe0d",
                "sha256": "2641cfbff1c768ff146858ed742d282b30a3a4c3e4f7717898705bbaee717736"
            },
            "downloads": -1,
            "filename": "st_pages-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "ff0bfb50d39c60da846907d3d7a6fe0d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "!=2.7.*,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*,!=3.8.*,>=3.9",
            "size": 21341,
            "upload_time": "2024-08-08T19:58:58",
            "upload_time_iso_8601": "2024-08-08T19:58:58.378728Z",
            "url": "https://files.pythonhosted.org/packages/83/60/f9516698fc3952bba1d1b6c1cb0795aa82dac12473f5fb678066532268e0/st_pages-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-08 19:58:58",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "st-pages"
}
        
Elapsed time: 0.30514s