Giter Club home page Giter Club logo

streamlit-extras's Introduction


PyPI version

🪢 streamlit-extras

A Python library with useful Streamlit extras

streamlit-extras is a Python library putting together useful Streamlit bits of code (extras).

CleanShot 2023-10-18 at 14 56 43

Highlights

  • 📙  Discover: Visit our documentation to discover all extras.
  • ⬇️  Install: streamlit-extras is a PyPI package with all extras included. Get them all using pip!
  • 🫴  Share: Go ahead and share your own extras, it's just a PR away!

Getting Started

Installation

pip install streamlit-extras

Usage

Here's an example with one of the easiest extras around, stoggle

from streamlit_extras.stoggle import stoggle

stoggle(
    "Click me!",
    """🥷 Surprise! Here's some additional content""",
)

Documentation

Visit https://arnaudmiribel.github.io/streamlit-extras

Contribution

PRs are welcome! Guidelines here

README template taken from LukasMasuch/streamlit-pydantic

streamlit-extras's People

Contributors

arnaudmiribel avatar asaurus1 avatar blackary avatar dependabot[bot] avatar gamcoh avatar kajarenc avatar lukasmasuch avatar nishu0 avatar r-moret avatar rjchauhan18 avatar sfc-gh-bhess avatar sfc-gh-jcarroll avatar sfc-gh-maliu avatar sfc-gh-trichards avatar shruagarwal avatar tomron avatar tylerjrichards avatar willhuang1997 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

streamlit-extras's Issues

Open in GitHub sticky button

Would be great to have an extra that makes an app play well with GitHub, and:

  • adds a sticky github button to reach the source code of an app Open in GitHub sorta
  • optionally adds the . trigger to open github.dev, too

API:

  • add_sticky_github_button(label="Open in GitHub", owner="arnaudmiribel", repository="streamlit-extras")
  • add_sticky_github_button(label="Open in GitHub", repository="arnaudmiribel/streamlit-extras")

Nothing inside init file after installed

Hi, i have recently installed streamlit_extras, but after importing the library and try to run the switch page function, i encountered a problem where it did not run. Checking the source code return nothing in init.py file. I have uninstalled then installed the package again, but the problem is still there.

Im currently running

  • Python 3.7
  • streamlit 1.15.2
  • Windows 11

Cannot find reference
inti.py

"Featured extra" badge?

Figured it could be nice to add this kind of badge on top of repositories readme/forum posts we eventually integrate inside streamlit-extras!

Mentions: only use <style> once

Since <style> blocks take vertical space in the app, avoid loading CSS each and every time a mention() is called! Call it only once.

Add minispark

Fun little addition to Altex to have mini charts

https://playground.streamlit.app?q=minispark

image

Code

import yfinance
import pandas as pd 
import yfinance as yf
from streamlit_extras.altex import sparkline_chart
import altair as alt 

msft = yf.Ticker("MSFT")
data = msft.history().reset_index()

def minispark(data: pd.DataFrame, x: str = "record_date:T", y: str = "cost") -> None:
    sparkline_chart(
        data=data,
        x=x,
        y=alt.Y(
            y + ":Q",
            scale=alt.Scale(domain=[data[y].min(), data[y].max()]),
        ),
        height=80,
    )
    
left, middle, right = st.columns(3)
with left:
    st.metric("Average Open", int(data["Open"].mean()))
    minispark(data, x="Date", y="Open")
with middle:
    st.metric("Average Close", int(data["Close"].mean()))
    minispark(data, x="Date", y="Close")
with right:
    st.metric("Average Volume", int(data["Volume"].mean()))
    minispark(data, x="Date", y="Open")

Load app_logo from disk

It would be nice to have an option to use a local file in the project as the app_logo.

It is described how to encode the data for use at stackoverflow:
https://stackoverflow.com/questions/73251012/put-logo-and-title-above-on-top-of-page-navigation-in-sidebar-of-streamlit-multi

Right now I have used a hack like this:

def get_base64_of_bin_file(png_file):
    with open(png_file, "rb") as f:
        data = f.read()
    return base64.b64encode(data).decode()

logo = "data:image/png;base64," + get_base64_of_bin_file("project/data/logo.png")

add_logo(logo)

Separate gallery from package

Could have two folders, one for actual extras, one for the gallery app (and the gallery app could have a separate, tighter set of dependencies).

That way we can have much looser requirements on the package itself.

streamlit_extras\__init__.py: IndexError: list index out of range

Hi,

I get following exception:
Traceback (most recent call last):
File "c:/Users/Public/Documents/BankAccount/test_drop.py", line 2, in
from streamlit_extras.dataframe_explorer import dataframe_explorer
File "C:\Python38\lib\site-packages\streamlit_extras\dataframe_explorer_init_.py", line 16, in
def dataframe_explorer(df: pd.DataFrame) -> pd.DataFrame:
File "C:\Python38\lib\site-packages\streamlit_extras_init_.py", line 41, in extra
submodule = filename.split("/")[-2]
IndexError: list index out of range

My code:

from streamlit_extras.dataframe_explorer import dataframe_explorer

Yes, 1 line.

Used versions:
Python 3.8.5

streamlit 1.15.1
streamlit-extras 0.2.2

Cleaner way to register an extra

Replace this

__func__ = get_streamlit_faker
__title__ = "Streamlit Faker"
__desc__ = "Fake Streamlit commands at the speed of light! Great for prototyping apps."
__icon__ = "🥷"
__examples__ = [example]
__author__ = "Arnaud Miribel"
__github_repo__ = "arnaudmiribel/streamlit-faker"
__pypi_name__ = "streamlit-faker"
__package_name__ = "streamlit_faker"
__experimental_playground__ = False

With

from common import set_extra_gallery_config

extra_gallery_config: dict = set_extra_gallery_config(
  func=get_streamlit_faker,
  title="Streamlit Faker",
  desc="Fake Streamlit commands at the speed of light! Great for prototyping apps.",
  ...
)

And consume that extra_gallery_config variable in gallery/streamlit_app.py.

Main perks:

  • canonical definition of all potential config keys in set_extra_gallery_config
  • auto-complete unlocked for all extra configs config
  • makes it clear that this part in the init.py is for the gallery and has no impact whatsoever in the inner workings of the extra.

Generalize function_explorer

  • Handle unhandled arguments by skipping them, rather than defaulting to a string
  • Allow ability to st.write outputs of functions

e.g. json.loads should be usable :)

Add https://baseweb.design/components/modal/

Potentials ideas:

  • Content
  • Some sort of dictionary specifying input elements (e.g. {"username": "text", "password": "password"})
  • Returns the value of input elements on submit

Passing args in the switch_page function

Hi all,

Is there a way to pass an argument with the switch_page function?
Given the fact that the function can't be inserted in the "on-click" parameter of a button it would be quite useful to have the possibility to pass some arguments. Could be this a possible ER? Or is there already a way to perform this action?

Thank you
Regards,
Lorenzo

Not working with the new release of Streamlit 1.14.0

There is a problem with the Rerun function. It has been renamed in the new version and it's raising problems with the switch_page functionality (That has not been updated in the new version of streamlit-extras). Is there any plan to fix this issue? Thank you.

[Workaround for the moment is to downgrade streamlit at 1.13.0 and keep working with that one]

No module named 'streamlit.runtime' for switch_page_button

Thanks for the great package!

I came across the following error when using switch_page_button, e.g. switch_page("Page2")

ModuleNotFoundError: No module named 'streamlit.runtime'

Traceback: from streamlit.runtime.scriptrunner import RerunData, RerunException

TODO: Add tests

Would be good to at least test that every component has the required __x__ attributes

Unable to install under 3.10 Python

Hi All, fantastic addons! I try them on Streamlit Cloud, but unable to install on local Python 3.10, seems like 3.9 works. Is there a solution? Thanks!

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.