st-cookie


Namest-cookie JSON
Version 0.2.1 PyPI version JSON
download
home_pagehttps://github.com/xtliu97/st_cookie
SummaryStreamlit Cookie Writer and Reader
upload_time2024-09-04 03:18:56
maintainerNone
docs_urlNone
authorxtliu97
requires_python>=3.8
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # st_cookie 
## What 
`st_cookie` is a Python package that allows you to store and retrieve data in a cookie. 

## Installation
```bash
pip install st-cookie
```

## Usage
- import
```python
from st_cookie import cookie_manager
```

- Usage 1  
Use `cookie_manager.load_to_session_state()` to load all the variables from cookies to session state. Use `cookie_manager.update()` to update session states to cookies with `on_change` or `on_click` callback of streamlit components.
```python
cookie_manager.load_to_session_state()

st.checkbox(
    "enabled",
    key="my_checkbox",
    on_change=lambda: cookie_manager.update("my_checkbox"),
)
```

- Usage 2  
Use context manager `cookie_manager.sync()` to sync variables to between cookies and session states.
```python
with cookie_manager.sync("my_textinput", "my_number"):
    st.text_input("Enter text", key="my_textinput")
    st.number_input("Enter number", key="my_number")
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/xtliu97/st_cookie",
    "name": "st-cookie",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "xtliu97",
    "author_email": "xtliu1112@outlook.com",
    "download_url": "https://files.pythonhosted.org/packages/b8/28/2867ce0faef6f48f2540489153bc86c7a32215756aa0f3c077cd894b451e/st_cookie-0.2.1.tar.gz",
    "platform": null,
    "description": "# st_cookie \n## What \n`st_cookie` is a Python package that allows you to store and retrieve data in a cookie. \n\n## Installation\n```bash\npip install st-cookie\n```\n\n## Usage\n- import\n```python\nfrom st_cookie import cookie_manager\n```\n\n- Usage 1  \nUse `cookie_manager.load_to_session_state()` to load all the variables from cookies to session state. Use `cookie_manager.update()` to update session states to cookies with `on_change` or `on_click` callback of streamlit components.\n```python\ncookie_manager.load_to_session_state()\n\nst.checkbox(\n    \"enabled\",\n    key=\"my_checkbox\",\n    on_change=lambda: cookie_manager.update(\"my_checkbox\"),\n)\n```\n\n- Usage 2  \nUse context manager `cookie_manager.sync()` to sync variables to between cookies and session states.\n```python\nwith cookie_manager.sync(\"my_textinput\", \"my_number\"):\n    st.text_input(\"Enter text\", key=\"my_textinput\")\n    st.number_input(\"Enter number\", key=\"my_number\")\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Streamlit Cookie Writer and Reader",
    "version": "0.2.1",
    "project_urls": {
        "Homepage": "https://github.com/xtliu97/st_cookie"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b8282867ce0faef6f48f2540489153bc86c7a32215756aa0f3c077cd894b451e",
                "md5": "f3df753972a8a486777d37a6d81a72b4",
                "sha256": "12b24ca4f8620b7abc9b9a3b4fa8bef134663b7b1fd07f4e02f424ecc0debbbe"
            },
            "downloads": -1,
            "filename": "st_cookie-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "f3df753972a8a486777d37a6d81a72b4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 4041,
            "upload_time": "2024-09-04T03:18:56",
            "upload_time_iso_8601": "2024-09-04T03:18:56.842094Z",
            "url": "https://files.pythonhosted.org/packages/b8/28/2867ce0faef6f48f2540489153bc86c7a32215756aa0f3c077cd894b451e/st_cookie-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-04 03:18:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "xtliu97",
    "github_project": "st_cookie",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "st-cookie"
}
        
Elapsed time: 0.31895s