streamlit-plugins


Namestreamlit-plugins JSON
Version 0.2.2 PyPI version JSON
download
home_pagehttps://github.com/quiradev/streamlit-plugins
SummaryComponents and Frameworks to give new features to streamlit
upload_time2024-07-08 13:36:30
maintainerNone
docs_urlNone
authorVictor Quilon Ranera
requires_python>=3.9
licenseMIT
keywords streamlit plugins framework components navbar loader multilit
VCS
bugtrack_url
requirements streamlit compress-pickle bokeh validators pandas
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # streamlit-plugins
Components and Frameworks to give new features to streamlit

![Demo Multipage with Navbar](https://raw.githubusercontent.com/quiradev/streamlit-plugins/main/resources/demo1.gif)

## Frameworks
### Multilit (Inherit from Hydralit)
This is a fork of [Hydralit](https://github.com/TangleSpace/hydralit).

In this version, I update all the code to be compatible with the last version of streamlit.
And it improves the interface to be more user-friendly. Also, it respects the strealit active theme and can be override by the user.
In a future is planned to incorporate the new multipage native of streamlit. Instead of the current implementation.

Can use built-in buttons to change the page, or use a function to change the page programmatically.
![Change Page with button](https://raw.githubusercontent.com/quiradev/streamlit-plugins/main/resources/demo2.gif)

## Components
The Navbar and Loader component are inherited from Hydralit components, only to give support to the multilit framework.
But this version has improve the interface and loaders to be more user-friendly.

### Navbar (Inherit from Hydralit Components)
Component to use when you want to have a navbar in your streamlit app.
It can be used with native multipage streamlit, or use the multilit framework.

If you want to use the native multipage streamlit, you can use the `st_navbar` function to create the navbar.

This component it returns the id of the defined menu that has to run the page.

This is an example of multipage with native streamlit
```python
import streamlit as st

if "logged_in" not in st.session_state:
    st.session_state.logged_in = False

def login():
    if st.button("Log in"):
        st.session_state.logged_in = True
        st.rerun()

def logout():
    if st.button("Log out"):
        st.session_state.logged_in = False
        st.rerun()

login_page = st.Page(login, title="Log in", icon=":material/login:")
logout_page = st.Page(logout, title="Log out", icon=":material/logout:")

dashboard = st.Page(
    "reports/dashboard.py", title="Dashboard", icon=":material/dashboard:", default=True
)
bugs = st.Page("reports/bugs.py", title="Bug reports", icon=":material/bug_report:")
alerts = st.Page(
    "reports/alerts.py", title="System alerts", icon=":material/notification_important:"
)

search = st.Page("tools/search.py", title="Search", icon=":material/search:")
history = st.Page("tools/history.py", title="History", icon=":material/history:")

if st.session_state.logged_in:
    pg = st.navigation(
        {
            "Account": [logout_page],
            "Reports": [dashboard, bugs, alerts],
            "Tools": [search, history],
        }
    )
else:
    pg = st.navigation([login_page])

pg.run()
```

And if you want to use streamlit Navbar, it has to be addapted to this code:
```python
import streamlit as st

st.set_page_config(layout="wide")

if "logged_in" not in st.session_state:
    st.session_state.logged_in = False

if "app_id" not in st.session_state:
    st.session_state.app_id = None

def login():
    if st.button("Log in"):
        st.session_state.logged_in = True
        st.session_state.app_id = "app_default"
        st.rerun()

def logout():
    if st.button("Log out"):
        st.session_state.logged_in = False
        st.session_state.app_id = None
        st.rerun()


login_page = st.Page(login, title="Log in", icon=":material/login:")
logout_page = st.Page(logout, title="Log out", icon=":material/logout:")

dashboard = st.Page(
    "reports/dashboard.py", title="Dashboard", icon=":material/dashboard:", default=True
)
bugs = st.Page("reports/bugs.py", title="Bug reports", icon=":material/bug_report:")
alerts = st.Page(
    "reports/alerts.py", title="System alerts", icon=":material/notification_important:"
)

search = st.Page("tools/search.py", title="Search", icon=":material/search:")
history = st.Page("tools/history.py", title="History", icon=":material/history:")

# HERE IS THE CHANGE
from streamlit_plugins.components.navbar import st_navbar, build_menu_from_st_pages

menu_data, app_map = build_menu_from_st_pages(
    {"Reports": [dashboard, bugs, alerts]}, {"Tools": [search, history]},
    login_app=login_page,
    logout_app=logout_page,
)

app_id = st_navbar(
    menu_definition=menu_data if st.session_state.logged_in else [],
    login_name=logout_page.title if st.session_state.logged_in else login_page.title,
    hide_streamlit_markers=False,
    override_app_selected_id=st.session_state.app_id,
    sticky_nav=True,  # at the top or not
    sticky_mode='pinned',  # sticky or pinned
)
if app_id == "app_login":
    if st.session_state.logged_in:
        app_id = "app_logout"

st.session_state.app_id = None  # Added to fix login/logout issue
app_map[app_id]._can_be_called = True
app_map[app_id].run()


# if st.session_state.logged_in:
#     pg = st.navigation(
#         {
#             "Account": [logout_page],
#             "Reports": [dashboard, bugs, alerts],
#             "Tools": [search, history],
#         },
#         position="hidden"
#     )
#
# else:
#     pg = st.navigation([login_page], position="hidden")
#
#
# pg.run()
```

### Loader (Inherit from Hydralit Components)

### AnnotatedText (Inspired from SpaCy Anotated Text)

### LabelStudio (Developing)
LabelStudio adapter for NERs into streamlit

### SnakeViz
Interface in streamlit to measue bottlenecks in yout code

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/quiradev/streamlit-plugins",
    "name": "streamlit-plugins",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "streamlit, plugins, framework, components, navbar, loader, multilit",
    "author": "Victor Quilon Ranera",
    "author_email": "v.quilonr@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/64/9e/9f022391340a0f12ec5d1f4dcef2b1412c1ec7eb7d6226cbbdb664eb1a16/streamlit_plugins-0.2.2.tar.gz",
    "platform": null,
    "description": "# streamlit-plugins\nComponents and Frameworks to give new features to streamlit\n\n![Demo Multipage with Navbar](https://raw.githubusercontent.com/quiradev/streamlit-plugins/main/resources/demo1.gif)\n\n## Frameworks\n### Multilit (Inherit from Hydralit)\nThis is a fork of [Hydralit](https://github.com/TangleSpace/hydralit).\n\nIn this version, I update all the code to be compatible with the last version of streamlit.\nAnd it improves the interface to be more user-friendly. Also, it respects the strealit active theme and can be override by the user.\nIn a future is planned to incorporate the new multipage native of streamlit. Instead of the current implementation.\n\nCan use built-in buttons to change the page, or use a function to change the page programmatically.\n![Change Page with button](https://raw.githubusercontent.com/quiradev/streamlit-plugins/main/resources/demo2.gif)\n\n## Components\nThe Navbar and Loader component are inherited from Hydralit components, only to give support to the multilit framework.\nBut this version has improve the interface and loaders to be more user-friendly.\n\n### Navbar (Inherit from Hydralit Components)\nComponent to use when you want to have a navbar in your streamlit app.\nIt can be used with native multipage streamlit, or use the multilit framework.\n\nIf you want to use the native multipage streamlit, you can use the `st_navbar` function to create the navbar.\n\nThis component it returns the id of the defined menu that has to run the page.\n\nThis is an example of multipage with native streamlit\n```python\nimport streamlit as st\n\nif \"logged_in\" not in st.session_state:\n    st.session_state.logged_in = False\n\ndef login():\n    if st.button(\"Log in\"):\n        st.session_state.logged_in = True\n        st.rerun()\n\ndef logout():\n    if st.button(\"Log out\"):\n        st.session_state.logged_in = False\n        st.rerun()\n\nlogin_page = st.Page(login, title=\"Log in\", icon=\":material/login:\")\nlogout_page = st.Page(logout, title=\"Log out\", icon=\":material/logout:\")\n\ndashboard = st.Page(\n    \"reports/dashboard.py\", title=\"Dashboard\", icon=\":material/dashboard:\", default=True\n)\nbugs = st.Page(\"reports/bugs.py\", title=\"Bug reports\", icon=\":material/bug_report:\")\nalerts = st.Page(\n    \"reports/alerts.py\", title=\"System alerts\", icon=\":material/notification_important:\"\n)\n\nsearch = st.Page(\"tools/search.py\", title=\"Search\", icon=\":material/search:\")\nhistory = st.Page(\"tools/history.py\", title=\"History\", icon=\":material/history:\")\n\nif st.session_state.logged_in:\n    pg = st.navigation(\n        {\n            \"Account\": [logout_page],\n            \"Reports\": [dashboard, bugs, alerts],\n            \"Tools\": [search, history],\n        }\n    )\nelse:\n    pg = st.navigation([login_page])\n\npg.run()\n```\n\nAnd if you want to use streamlit Navbar, it has to be addapted to this code:\n```python\nimport streamlit as st\n\nst.set_page_config(layout=\"wide\")\n\nif \"logged_in\" not in st.session_state:\n    st.session_state.logged_in = False\n\nif \"app_id\" not in st.session_state:\n    st.session_state.app_id = None\n\ndef login():\n    if st.button(\"Log in\"):\n        st.session_state.logged_in = True\n        st.session_state.app_id = \"app_default\"\n        st.rerun()\n\ndef logout():\n    if st.button(\"Log out\"):\n        st.session_state.logged_in = False\n        st.session_state.app_id = None\n        st.rerun()\n\n\nlogin_page = st.Page(login, title=\"Log in\", icon=\":material/login:\")\nlogout_page = st.Page(logout, title=\"Log out\", icon=\":material/logout:\")\n\ndashboard = st.Page(\n    \"reports/dashboard.py\", title=\"Dashboard\", icon=\":material/dashboard:\", default=True\n)\nbugs = st.Page(\"reports/bugs.py\", title=\"Bug reports\", icon=\":material/bug_report:\")\nalerts = st.Page(\n    \"reports/alerts.py\", title=\"System alerts\", icon=\":material/notification_important:\"\n)\n\nsearch = st.Page(\"tools/search.py\", title=\"Search\", icon=\":material/search:\")\nhistory = st.Page(\"tools/history.py\", title=\"History\", icon=\":material/history:\")\n\n# HERE IS THE CHANGE\nfrom streamlit_plugins.components.navbar import st_navbar, build_menu_from_st_pages\n\nmenu_data, app_map = build_menu_from_st_pages(\n    {\"Reports\": [dashboard, bugs, alerts]}, {\"Tools\": [search, history]},\n    login_app=login_page,\n    logout_app=logout_page,\n)\n\napp_id = st_navbar(\n    menu_definition=menu_data if st.session_state.logged_in else [],\n    login_name=logout_page.title if st.session_state.logged_in else login_page.title,\n    hide_streamlit_markers=False,\n    override_app_selected_id=st.session_state.app_id,\n    sticky_nav=True,  # at the top or not\n    sticky_mode='pinned',  # sticky or pinned\n)\nif app_id == \"app_login\":\n    if st.session_state.logged_in:\n        app_id = \"app_logout\"\n\nst.session_state.app_id = None  # Added to fix login/logout issue\napp_map[app_id]._can_be_called = True\napp_map[app_id].run()\n\n\n# if st.session_state.logged_in:\n#     pg = st.navigation(\n#         {\n#             \"Account\": [logout_page],\n#             \"Reports\": [dashboard, bugs, alerts],\n#             \"Tools\": [search, history],\n#         },\n#         position=\"hidden\"\n#     )\n#\n# else:\n#     pg = st.navigation([login_page], position=\"hidden\")\n#\n#\n# pg.run()\n```\n\n### Loader (Inherit from Hydralit Components)\n\n### AnnotatedText (Inspired from SpaCy Anotated Text)\n\n### LabelStudio (Developing)\nLabelStudio adapter for NERs into streamlit\n\n### SnakeViz\nInterface in streamlit to measue bottlenecks in yout code\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Components and Frameworks to give new features to streamlit",
    "version": "0.2.2",
    "project_urls": {
        "Homepage": "https://github.com/quiradev/streamlit-plugins"
    },
    "split_keywords": [
        "streamlit",
        " plugins",
        " framework",
        " components",
        " navbar",
        " loader",
        " multilit"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e8a0c16cba549d30d3da7974929324ed1076285cacffabe5a28c6d9637c09e17",
                "md5": "9535a4859eac641bb845eef0b2d8a460",
                "sha256": "9b8434eaa1666f22c421d5be5c279f76079fe925a589f89f0c730a2835af351f"
            },
            "downloads": -1,
            "filename": "streamlit_plugins-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9535a4859eac641bb845eef0b2d8a460",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 1613742,
            "upload_time": "2024-07-08T13:36:27",
            "upload_time_iso_8601": "2024-07-08T13:36:27.169038Z",
            "url": "https://files.pythonhosted.org/packages/e8/a0/c16cba549d30d3da7974929324ed1076285cacffabe5a28c6d9637c09e17/streamlit_plugins-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "649e9f022391340a0f12ec5d1f4dcef2b1412c1ec7eb7d6226cbbdb664eb1a16",
                "md5": "5fab3475299b54c7f2a52d0ef06a31b5",
                "sha256": "1e7cd8c337a74cd5b56b533a0bcf3206c2fdca4b12105abfb10de90ce2f63342"
            },
            "downloads": -1,
            "filename": "streamlit_plugins-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "5fab3475299b54c7f2a52d0ef06a31b5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 1586410,
            "upload_time": "2024-07-08T13:36:30",
            "upload_time_iso_8601": "2024-07-08T13:36:30.294087Z",
            "url": "https://files.pythonhosted.org/packages/64/9e/9f022391340a0f12ec5d1f4dcef2b1412c1ec7eb7d6226cbbdb664eb1a16/streamlit_plugins-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-08 13:36:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "quiradev",
    "github_project": "streamlit-plugins",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "streamlit",
            "specs": [
                [
                    "<=",
                    "1.37.0"
                ]
            ]
        },
        {
            "name": "compress-pickle",
            "specs": [
                [
                    "~=",
                    "2.1.0"
                ]
            ]
        },
        {
            "name": "bokeh",
            "specs": [
                [
                    "~=",
                    "3.1.1"
                ]
            ]
        },
        {
            "name": "validators",
            "specs": [
                [
                    "~=",
                    "0.22.0"
                ]
            ]
        },
        {
            "name": "pandas",
            "specs": [
                [
                    "~=",
                    "2.2.0"
                ]
            ]
        }
    ],
    "lcname": "streamlit-plugins"
}
        
Elapsed time: 0.39803s