Here’s the outline of an app, but I want it to be way more functional and even more kawaii.
To upload files, please first save the app
import streamlit as st
import pandas as pd
import numpy as np
from st_aggrid import AgGrid, GridOptionsBuilder, JsCode
import datetime
# Set page config for a wider layout and kawaii title
st.set_page_config(
page_title="✨ Kawaii Data Grid ✨",
page_icon="🌸",
layout="wide"
)
# Custom CSS for kawaii styling
st.markdown("""
<style>
.stApp {
background: linear-gradient(135deg, #ffe6f2 0%, #fff2f9 100%);
}
h1, h2, h3 {
color: #ff66b2 !important;
font-family: 'Arial Rounded MT Bold', sans-serif;
}
.stButton>button {
border-radius: 20px;
background-color: #ff99cc;
color: white;
border: none;
padding: 10px 20px;
transition: all 0.3s ease;
}
.stButton>button:hover {
background-color: #ff66b2;
transform: scale(1.05);
}
div[data-baseweb="select"] {
border-radius: 15px;
}
.ag-theme-streamlit {
--ag-header-background-color: #ffb3d9;
--ag-header-foreground-color: white;
--ag-odd-row-background-color: #fff5f9;
--ag-row-hover-color: #ffe6f2;
}
</style>
""", unsafe_allow_html=True)
# Kawaii title and description
st.title("🌸 Super Kawaii Data Grid 🌸")
st.markdown("### ✨ Let's make data analysis cute and fun! ✨")
# Function to generate sample data
@st.cache_data
def generate_kawaii_data(rows=100):
kawaii_items = ['🎀 Ribbon', '🧸 Teddy Bear', '🦄 Unicorn', '🌈 Rainbow', '🍰 Cake',
'🎪 Circus', '🎠 Carousel', '🪆 Doll', '🎨 Art Set', '🎭 Mask']
kawaii_colors = ['Pink', 'Pastel Blue', 'Lavender', 'Mint Green', 'Peach']
kawaii_categories = ['Cute', 'Super Cute', 'Ultra Cute', 'Mega Cute', 'Ultimate Cute']
data = {
'Item': np.random.choice(kawaii_items, rows),
'Color': np.random.choice(kawaii_colors, rows),
'Category': np.random.choice(kawaii_categories, rows),
'Cuteness_Level': np.random.randint(1, 101, rows),
'Price': np.random.uniform(10, 100, rows).round(2),
'Stock': np.random.randint(0, 1000, rows),
'Last_Restocked': [datetime.datetime.now() - datetime.timedelta(days=x) for x in np.random.randint(0, 30, rows)]
}
return pd.DataFrame(data)
# Generate initial data
df = generate_kawaii_data()
# Sidebar controls
st.sidebar.markdown("## 🌟 Kawaii Controls 🌟")
rows = st.sidebar.slider("Number of Rows", 10, 1000, 100, 10)
if st.sidebar.button("✨ Generate New Data ✨"):
df = generate_kawaii_data(rows)
# Custom cell renderer for cuteness level
cuteness_renderer = JsCode("""
function(params) {
const hearts = '💖'.repeat(Math.ceil(params.value/20));
return `<div style="text-align: left;">
<div style="font-weight: bold;">${params.value}</div>
<div>${hearts}</div>
</div>`;
}
""")
# Configure grid options
gb = GridOptionsBuilder.from_dataframe(df)
gb.configure_column('Cuteness_Level', cellRenderer=cuteness_renderer)
gb.configure_column('Price', valueFormatter="'$' + value.toFixed(2)")
gb.configure_column('Last_Restocked', type=["dateColumnFilter","customDateTimeFormat"],
custom_format_string='yyyy-MM-dd HH:mm')
gb.configure_selection('multiple', use_checkbox=True)
gb.configure_side_bar()
gb.configure_grid_options(enableRangeSelection=True, rowHeight=60)
gridOptions = gb.build()
# Main content area with tabs
tab1, tab2, tab3 = st.tabs(['📊 Data Grid', '📈 Analytics', '💝 Selected Items'])
with tab1:
grid_response = AgGrid(
df,
gridOptions=gridOptions,
height=500,
theme='streamlit',
enable_enterprise_modules=True,
update_mode='MODEL_CHANGED',
allow_unsafe_jscode=True
)
with tab2:
st.markdown("### 📊 Kawaii Analytics")
col1, col2 = st.columns(2)
with col1:
st.markdown("#### Average Cuteness by Category")
category_stats = df.groupby('Category')['Cuteness_Level'].mean().round(2)
st.bar_chart(category_stats)
with col2:
st.markdown("#### Items by Color")
color_counts = df['Color'].value_counts()
st.pie_chart(color_counts)
st.markdown("#### Stock Levels Overview")
st.line_chart(df.groupby('Item')['Stock'].sum())
with tab3:
selected_rows = grid_response['selected_rows']
if selected_rows:
st.markdown("### 💖 Selected Kawaii Items 💖")
selected_df = pd.DataFrame(selected_rows)
# Calculate total value
total_value = (selected_df['Price'] * selected_df['Stock']).sum()
col1, col2, col3 = st.columns(3)
with col1:
st.metric("Total Items", len(selected_rows))
with col2:
st.metric("Average Cuteness", f"{selected_df['Cuteness_Level'].mean():.1f}")
with col3:
st.metric("Total Value", f"${total_value:,.2f}")
st.table(selected_df)
else:
st.info("✨ Select some rows from the grid to see their details here! ✨")
# Footer
st.markdown("""
---
<div style='text-align: center; color: #ff66b2;'>
Made with 💖 by your Kawaii Data Assistant
</div>
""", unsafe_allow_html=True)
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?