import streamlit as st from PIL import Image import os st.title("Our History in Data") # Set the global index path global_index_path = "data/immaterial_index/figures_trends_R/results" unseen_index_path = ( "data/immaterial_index/figures_trends_R/figures_unseen/results_unseen" ) unseen_capita_index_path = ( "data/immaterial_index/figures_trends_R/figures_unseen/results_unseen/per_capita" ) population_path = "data/population" maps_path = "data/map_figures" # Update image_paths using global_index_path index_paths = { "India": { "map": f"{maps_path}/map_Indian world.png", "global_index": f"{global_index_path}/india.png", "unseen_index": f"{unseen_index_path}/india.png", "unseen_index_capita": f"{unseen_capita_index_path}/india.png", "population_index": f"{population_path}/Indian world.png", }, "Japan": { "map": f"{maps_path}/map_Japan.png", "global_index": f"{global_index_path}/japan.png", "unseen_index": f"{unseen_index_path}/japan.png", "unseen_index_capita": f"{unseen_capita_index_path}/Japan.png", "population_index": f"{population_path}/Japan.png", }, "France": { "map": f"{maps_path}/map_France.png", "global_index": f"{global_index_path}/france.png", "unseen_index": f"{unseen_index_path}/france.png", "unseen_index_capita": f"{unseen_capita_index_path}/France.png", "population_index": f"{population_path}/France.png", }, "Italy": { "map": f"{maps_path}/map_Italy.png", "global_index": f"{global_index_path}/italy.png", "unseen_index": f"{unseen_index_path}/italy.png", "unseen_index_capita": f"{unseen_capita_index_path}/Italy.png", "population_index": f"{population_path}/Italy.png", }, "Spain": { "map": f"{maps_path}/map_Spain.png", "global_index": f"{global_index_path}/spain.png", "unseen_index": f"{unseen_index_path}/spain.png", "unseen_index_capita": f"{unseen_capita_index_path}/Spain.png", "population_index": f"{population_path}/Spain.png", }, } # Get the region names (keys) from the index_paths dictionary regions = list(index_paths.keys()) # Allow the user to select a region selected_region = st.sidebar.selectbox("Region:", regions) # Display the selected region's images vertically if selected_region in index_paths: for key, path in index_paths[selected_region].items(): if os.path.exists(path): if key == "global_index": st.subheader("Global Index") st.image( Image.open(path), caption=key.capitalize(), use_column_width=True ) elif key == "unseen_index": st.subheader("Unsee-Species Index") st.image( Image.open(path), caption=key.capitalize(), use_column_width=True ) elif key == "unseen_index_capita": st.subheader("Unsee-Species per capita Index") st.image( Image.open(path), caption=key.capitalize(), use_column_width=True ) elif key == "population_index": st.subheader("¨Population Index") st.image( Image.open(path), caption=key.capitalize(), use_column_width=True ) elif key == "map": st.subheader("Maps") st.sidebar.image( Image.open(path), caption=key.capitalize(), use_column_width=True ) else: st.write(f"File for {key.capitalize()} does not exist.") # Add more information or charts specific to India here else: st.write("Please select India as the region from the sidebar on the left.")