Skip to main content

🖼️ An image select component for Streamlit

Project description

streamlit-image-select 🖼️

PyPI

An image select component for Streamlit.

This custom component works just like st.selectbox but with images. It's a great option if you want to let the user select an example image, e.g. for a computer vision app!


🏃 Try out the demo app 🏃


Installation

pip install streamlit-image-select

Usage

from streamlit_image_select import image_select
img = image_select("Label", ["image1.png", "image2.png", "image3.png"])
st.write(img)

See the demo app for a detailed guide!

Development

Warning You only need to run these steps if you want to change this component or contribute to its development!

Setup

First, clone the repository:

git clone https://github.com/jrieke/streamlit-image-select.git
cd streamlit-image-select

Install the Python dependencies:

poetry install --dev

And install the frontend dependencies:

cd streamlit_image_select/frontend
npm install

Making changes

To make changes, first go to streamlit_image_select/__init__.py and make sure the variable _RELEASE is set to False. This will make the component use the local version of the frontend code, and not the built project.

Then, start one terminal and run:

cd streamlit_image_select/frontend
npm start

This starts the frontend code on port 3001.

Open another terminal and run:

cp demo/streamlit_app.py .
poetry shell
streamlit run streamlit_app.py

This copies the demo app to the root dir (so you have something to work with and see your changes!) and then starts it. Now you can make changes to the Python or Javascript code in streamlit_image_select and the demo app should update automatically!

If nothing updates, make sure the variable _RELEASE in streamlit_image_select/__init__.py is set to False.

Publishing on PyPI

Switch the variable _RELEASE in streamlit_image_select/__init__.py to True. Increment the version number in pyproject.toml. Make sure the copy of the demo app in the root dir is deleted or merged back into the demo app in demo/streamlit_app.py.

Build the frontend code with:

cd streamlit_image_select/frontend
npm run build

After this has finished, build and upload the package to PyPI:

cd ../..
poetry build
poetry publish

Changelog

0.7.0 (August 2, 2024)

  • Added parameter images_rows to be able to display the images in multiple rows.
  • If using images_rows, it is possible to add rudimentary tooltips.
  • Added parameter disabled to be able to disable the selector.
  • Added parameter custom_css to allow for custom styling of the whole component if the user whishes to.
  • Added the possibility to use html code in the label and captions parameters.

0.6.0 (March 28, 2023)

  • Removed st.experimental_memo, which is deprecated.
  • Changed minimum version of Streamlit to 1.19.

0.5.1 (November 20, 2022)

  • Hotfix, forgot to switch the RELEASE variable back to True :wink:

0.5.0 (November 20, 2022)

  • Added return_value parameter to be able to get the index of the selected image.
  • Improved error messages.

0.4.0 (November 20, 2022)

  • Added index parameter to set the initially selected image.
  • Improved input arg checks.

0.3.0 (November 13, 2022)

  • Added use_container_width parameter to customize the width of the component.
  • Made key and use_container_width parameters keyword-only.
  • Refactored CSS classes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamlit-image-select-rows-0.7.4.tar.gz (353.2 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file streamlit-image-select-rows-0.7.4.tar.gz.

File metadata

File hashes

Hashes for streamlit-image-select-rows-0.7.4.tar.gz
Algorithm Hash digest
SHA256 0193211d26b77ee0643e57e9692ec0f70acf14a3dc0f9484d24569b0b85191be
MD5 2724f885d7e1081652419e64d8481d29
BLAKE2b-256 3e17c3486e4b2dc24767835e88c61d2cf32bf4aa154c501b7d3b9d573940550c

See more details on using hashes here.

File details

Details for the file streamlit_image_select_rows-0.7.4-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_image_select_rows-0.7.4-py3-none-any.whl
Algorithm Hash digest
SHA256 bed113783b7eb7fd5cde51b876e257f8186a68d5220656fa7e64cb044e2391e8
MD5 f7ac26e03f2d09ef617ee8f9ad036d24
BLAKE2b-256 f1d35d3baebe05210c80594fde656b6b9b756dddcd9bbe7ba5b22141746bbe9c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page