Skip to content

Commit

Permalink
Update example app pages with new content.
Browse files Browse the repository at this point in the history
  • Loading branch information
hreikin committed Apr 1, 2023
1 parent f00221b commit 302c8e5
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 30 deletions.
7 changes: 3 additions & 4 deletions Home.py
Expand Up @@ -6,7 +6,6 @@
# Configure page title, layout, menu items and links.
st.set_page_config(
page_title="Streamlit Uploads Library",
layout="wide",
menu_items={
"Get Help": "https://github.com/hreikin/streamlit-uploads-library",
"Report a bug": "https://github.com/hreikin/streamlit-uploads-library/issues",
Expand All @@ -33,9 +32,9 @@
pip install streamlit-uploads-library
```
The file uploader can be seen in the sidebar and the library and gallery views are shown down
below. Using any of the provided views is easy, just import the class and then instantiate it.
Multiple options are able to be configured with more info available on the relevant pages. Here
The default file uploader can be seen in the sidebar and the library and gallery views are shown
down below. Using any of the provided views is easy, just import the class and then instantiate
it. Multiple options are able to be configured with more info available on the relevant pages. Here
is a code example that shows how to create the default library, gallery and file uploader views.
"""
)
Expand Down
1 change: 0 additions & 1 deletion pages/Library.py → pages/02_Library.py
Expand Up @@ -4,7 +4,6 @@
# Configure page title, layout, menu items and links.
st.set_page_config(
page_title="Streamlit Uploads Library",
layout="wide",
menu_items={
"Get Help": "https://github.com/hreikin/streamlit-uploads-library",
"Report a bug": "https://github.com/hreikin/streamlit-uploads-library/issues",
Expand Down
1 change: 0 additions & 1 deletion pages/Gallery.py → pages/03_Gallery.py
Expand Up @@ -4,7 +4,6 @@
# Configure page title, layout, menu items and links.
st.set_page_config(
page_title="Streamlit Uploads Library",
layout="wide",
menu_items={
"Get Help": "https://github.com/hreikin/streamlit-uploads-library",
"Report a bug": "https://github.com/hreikin/streamlit-uploads-library/issues",
Expand Down
46 changes: 23 additions & 23 deletions pages/Uploads.py → pages/04_Uploaders.py
Expand Up @@ -4,7 +4,6 @@
# Configure page title, layout, menu items and links.
st.set_page_config(
page_title="Streamlit Uploads Library",
layout="wide",
menu_items={
"Get Help": "https://github.com/hreikin/streamlit-uploads-library",
"Report a bug": "https://github.com/hreikin/streamlit-uploads-library/issues",
Expand Down Expand Up @@ -132,33 +131,34 @@ def save_uploaded_files(self, files_to_upload, destination):
st.markdown(
"""
The default uploader provides a container with a header, info message and file uploader and
can be created just by passing in a `save_location`. The second uploader provides an expander
with an optional label, info message and file uploader and can be created just by passing in a
`save_location` and the `widget_type`.
can be created just by passing in a `save_location`.
"""
)
col1, col2 = st.columns(2)
with col1:
st.code(
"""
import streamlit as st
from streamlit_uploads_library.uploads import UploadFiles

st.set_page_config(page_title="Streamlit Uploads Library")
default_uploader = UploadFiles(save_location="assets")
"""
st.code(
"""
import streamlit as st
from streamlit_uploads_library.uploads import UploadFiles
st.set_page_config(page_title="Streamlit Uploads Library")
default_uploader = UploadFiles(save_location="assets")
"""
)
default_uploader = UploadFiles(save_location="assets")
with col2:
st.code(
"""
import streamlit as st
from streamlit_uploads_library.uploads import UploadFiles
st.markdown(
"""
The second uploader provides an expander
with an optional label, info message and file uploader and can be created just by passing in a
`save_location` and the `widget_type`.
"""
)
st.code(
"""
import streamlit as st
from streamlit_uploads_library.uploads import UploadFiles
st.set_page_config(page_title="Streamlit Uploads Library")
expander = UploadFiles(save_location="assets", uid="expander-type", widget_type="expander")
"""
st.set_page_config(page_title="Streamlit Uploads Library")
expander = UploadFiles(save_location="assets", uid="expander-type", widget_type="expander")
"""
)
expander = UploadFiles(save_location="assets", uid="expander-type", widget_type="expander")
with st.expander(label="**Source Code**", expanded=True):
st.code(body=source_code)
29 changes: 28 additions & 1 deletion pages/Caching.py → pages/05_Advanced.py
Expand Up @@ -5,7 +5,6 @@
# Configure page title, layout, menu items and links.
st.set_page_config(
page_title="Streamlit Uploads Library",
layout="wide",
menu_items={
"Get Help": "https://github.com/hreikin/streamlit-uploads-library",
"Report a bug": "https://github.com/hreikin/streamlit-uploads-library/issues",
Expand All @@ -20,6 +19,34 @@
with st.sidebar:
st.info("Welcome to the `streamlit-uploads-library` example app.")

st.header("Custom File Details")
st.markdown(
"""
A default set of basic file details is provided for each image within the library. Using class
inheritance this can be overridden to create your own file details section if you wish to include
more information or different options.
"""
)
st.code(
"""
import streamlit as st
from streamlit_uploads_library.library import Library
class CustomLibrary(Library):
def __init__(self, directory, file_extensions=(".png", ".jpg", ".jpeg"), image_alignment="center", number_of_columns=5, show_details=True, uid="custom"):
self.directory = directory
self.file_extensions = file_extensions
self.image_alignment = image_alignment
self.number_of_columns = number_of_columns
self.show_details = show_details
self.uid = uid
super(CustomLibrary, self).__init__(self.directory, self.file_extensions, self.image_alignment, self.number_of_columns, self.show_details, self.uid)
def create_details(_self, img, filename_idx, uid):
# Your details section code here
"""
)

st.header("Caching")
st.markdown(
"""
Expand Down

0 comments on commit 302c8e5

Please sign in to comment.