Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update streamlit version #155

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish_new_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.8"
python-version: "3.10"
- name: Set up Node.js
uses: actions/setup-node@v3
with:
Expand Down
3 changes: 2 additions & 1 deletion e2e/app_to_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pandas as pd
import streamlit as st

from streamlit_drawable_canvas import st_canvas

st.header("End-to-end Cypress test")
Expand All @@ -17,4 +18,4 @@

if canvas_result.image_data is not None:
st.image(canvas_result.image_data)
st.dataframe(pd.json_normalize(canvas_result.json_data["objects"]))
df = pd.json_normalize(canvas_result.json_data["objects"])
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from os.path import dirname
from os.path import join
from os.path import dirname, join

import setuptools


Expand All @@ -15,7 +15,7 @@ def readme() -> str:

setuptools.setup(
name="streamlit-drawable-canvas",
version="0.9.3",
version="0.9.4",
author="Fanilo ANDRIANASOLO",
author_email="[email protected]",
description="A Streamlit custom component for a free drawing canvas using Fabric.js.",
Expand All @@ -25,10 +25,10 @@ def readme() -> str:
packages=setuptools.find_packages(),
include_package_data=True,
classifiers=[],
python_requires=">=3.6",
python_requires=">=3.10",
install_requires=[
"Pillow",
"numpy",
"streamlit >= 0.63",
]
"streamlit >= 1.40",
],
)
15 changes: 9 additions & 6 deletions streamlit_drawable_canvas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import numpy as np
import streamlit as st
import streamlit.components.v1 as components
import streamlit.elements.image as st_image
from PIL import Image
from streamlit.elements.lib.image_utils import image_to_url

_RELEASE = True # on packaging, pass this to True

Expand Down Expand Up @@ -122,16 +122,19 @@ def st_canvas(
if background_image:
background_image = _resize_img(background_image, height, width)
# Reduce network traffic and cache when switch another configure, use streamlit in-mem filemanager to convert image to URL
background_image_url = st_image.image_to_url(
background_image, width, True, "RGB", "PNG", f"drawable-canvas-bg-{md5(background_image.tobytes()).hexdigest()}-{key}"
background_image_url = image_to_url(
background_image,
width,
True,
"RGB",
"PNG",
f"drawable-canvas-bg-{md5(background_image.tobytes()).hexdigest()}-{key}",
)
background_image_url = st._config.get_option("server.baseUrlPath") + background_image_url
background_color = ""

# Clean initial drawing, override its background color
initial_drawing = (
{"version": "4.4.0"} if initial_drawing is None else initial_drawing
)
initial_drawing = {"version": "4.4.0"} if initial_drawing is None else initial_drawing
initial_drawing["background"] = background_color

component_value = _component_func(
Expand Down