Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +62 -63
src/streamlit_app.py
CHANGED
|
@@ -1,19 +1,19 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
import os
|
|
|
|
| 4 |
|
| 5 |
# ==============================================================================
|
| 6 |
-
# 1. STYLE CSS V2.
|
| 7 |
# ==============================================================================
|
| 8 |
-
st.set_page_config(page_title="Brake Lab V2", layout="centered")
|
| 9 |
|
| 10 |
st.markdown("""
|
| 11 |
<style>
|
| 12 |
-
/* 1.1 FOND GLOBAL BLANC */
|
| 13 |
.stApp { background-color: #FFFFFF !important; }
|
| 14 |
* { color: #000000 !important; font-family: 'Arial', sans-serif; }
|
| 15 |
|
| 16 |
-
/*
|
| 17 |
input[type="number"], .stNumberInput div[data-baseweb="input"] {
|
| 18 |
color: #FFFFFF !important;
|
| 19 |
background-color: #1E1E1E !important;
|
|
@@ -21,42 +21,25 @@ st.markdown("""
|
|
| 21 |
font-weight: bold !important;
|
| 22 |
border: 2px solid #000 !important;
|
| 23 |
}
|
| 24 |
-
input[type="number"] { color: #FFFFFF !important; }
|
| 25 |
|
| 26 |
-
/*
|
| 27 |
div[data-baseweb="select"] {
|
| 28 |
background-color: #1E1E1E !important;
|
| 29 |
border: 2px solid #000000 !important;
|
| 30 |
border-radius: 8px !important;
|
| 31 |
}
|
| 32 |
-
|
| 33 |
-
/* Texte sélectionné affiché dans la boite */
|
| 34 |
-
div[data-baseweb="select"] div {
|
| 35 |
-
color: #FFFFFF !important;
|
| 36 |
-
font-weight: bold !important;
|
| 37 |
-
}
|
| 38 |
|
| 39 |
-
/*
|
| 40 |
-
div[role="listbox"], ul[role="listbox"] {
|
| 41 |
-
|
| 42 |
-
}
|
| 43 |
-
|
| 44 |
-
/* Force le blanc sur tous les éléments internes de la liste */
|
| 45 |
-
li[role="option"],
|
| 46 |
-
li[role="option"] p,
|
| 47 |
-
li[role="option"] span,
|
| 48 |
-
li[role="option"] div {
|
| 49 |
color: #FFFFFF !important;
|
| 50 |
background-color: #1E1E1E !important;
|
| 51 |
font-weight: bold !important;
|
| 52 |
}
|
|
|
|
| 53 |
|
| 54 |
-
/*
|
| 55 |
-
li[role="option"]:hover {
|
| 56 |
-
background-color: #0082C3 !important;
|
| 57 |
-
}
|
| 58 |
-
|
| 59 |
-
/* 1.5 CARTES DE RÉSULTATS (NOMMÉES V2.1) */
|
| 60 |
.perf-box {
|
| 61 |
padding: 40px;
|
| 62 |
border: 4px solid #000000;
|
|
@@ -66,12 +49,7 @@ st.markdown("""
|
|
| 66 |
margin-top: 20px;
|
| 67 |
box-shadow: 8px 8px 0px #000;
|
| 68 |
}
|
| 69 |
-
.perf-value {
|
| 70 |
-
font-size: 60px; /* Légèrement plus grand car moins de texte */
|
| 71 |
-
font-weight: 900;
|
| 72 |
-
color: #0082C3 !important;
|
| 73 |
-
margin: 0px;
|
| 74 |
-
}
|
| 75 |
</style>
|
| 76 |
""", unsafe_allow_html=True)
|
| 77 |
|
|
@@ -90,47 +68,68 @@ def load_data():
|
|
| 90 |
df = load_data()
|
| 91 |
|
| 92 |
# ==============================================================================
|
| 93 |
-
# 3. INTERFACE V2.
|
| 94 |
# ==============================================================================
|
| 95 |
if not df.empty:
|
| 96 |
-
# --- LOGO ET TITRE SUPPRIMÉS ---
|
| 97 |
-
|
| 98 |
-
st.write("") # Espace de tête
|
| 99 |
|
| 100 |
-
#
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
model_list = df['model name'].unique().tolist()
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
res_dry = row['dry a'] * effort_val + row['dry b']
|
| 113 |
res_wet = row['wet a'] * effort_val + row['wet b']
|
| 114 |
|
| 115 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
st.write("")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
res_c1, res_c2 = st.columns(2)
|
| 118 |
|
| 119 |
with res_c1:
|
| 120 |
-
st.markdown(f"""
|
| 121 |
-
<
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
""", unsafe_allow_html=True)
|
| 126 |
|
| 127 |
with res_c2:
|
| 128 |
-
st.markdown(f"""
|
| 129 |
-
<
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
""", unsafe_allow_html=True)
|
| 134 |
|
| 135 |
else:
|
| 136 |
-
st.error("Erreur :
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
import os
|
| 4 |
+
import numpy as np
|
| 5 |
|
| 6 |
# ==============================================================================
|
| 7 |
+
# 1. STYLE CSS V2.2 (SOCLE INVIOLABLE)
|
| 8 |
# ==============================================================================
|
| 9 |
+
st.set_page_config(page_title="Brake Lab V2.2", layout="centered")
|
| 10 |
|
| 11 |
st.markdown("""
|
| 12 |
<style>
|
|
|
|
| 13 |
.stApp { background-color: #FFFFFF !important; }
|
| 14 |
* { color: #000000 !important; font-family: 'Arial', sans-serif; }
|
| 15 |
|
| 16 |
+
/* INPUTS : TEXTE BLANC SUR NOIR */
|
| 17 |
input[type="number"], .stNumberInput div[data-baseweb="input"] {
|
| 18 |
color: #FFFFFF !important;
|
| 19 |
background-color: #1E1E1E !important;
|
|
|
|
| 21 |
font-weight: bold !important;
|
| 22 |
border: 2px solid #000 !important;
|
| 23 |
}
|
|
|
|
| 24 |
|
| 25 |
+
/* SELECTBOX : BLANC SUR NOIR */
|
| 26 |
div[data-baseweb="select"] {
|
| 27 |
background-color: #1E1E1E !important;
|
| 28 |
border: 2px solid #000000 !important;
|
| 29 |
border-radius: 8px !important;
|
| 30 |
}
|
| 31 |
+
div[data-baseweb="select"] div { color: #FFFFFF !important; font-weight: bold !important; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
+
/* LISTE DÉROULANTE (VISIBILITÉ) */
|
| 34 |
+
div[role="listbox"], ul[role="listbox"] { background-color: #1E1E1E !important; }
|
| 35 |
+
li[role="option"], li[role="option"] p, li[role="option"] span, li[role="option"] div {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
color: #FFFFFF !important;
|
| 37 |
background-color: #1E1E1E !important;
|
| 38 |
font-weight: bold !important;
|
| 39 |
}
|
| 40 |
+
li[role="option"]:hover { background-color: #0082C3 !important; }
|
| 41 |
|
| 42 |
+
/* CARTES DE RÉSULTATS */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
.perf-box {
|
| 44 |
padding: 40px;
|
| 45 |
border: 4px solid #000000;
|
|
|
|
| 49 |
margin-top: 20px;
|
| 50 |
box-shadow: 8px 8px 0px #000;
|
| 51 |
}
|
| 52 |
+
.perf-value { font-size: 55px; font-weight: 900; color: #0082C3 !important; margin: 0px; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
</style>
|
| 54 |
""", unsafe_allow_html=True)
|
| 55 |
|
|
|
|
| 68 |
df = load_data()
|
| 69 |
|
| 70 |
# ==============================================================================
|
| 71 |
+
# 3. INTERFACE V2.2 : ARCHITECTURE 2 BLOCS
|
| 72 |
# ==============================================================================
|
| 73 |
if not df.empty:
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
+
# --- BLOC 1 : DONNÉES D'USAGE ---
|
| 76 |
+
with st.expander("📊 Données d'usage", expanded=False):
|
| 77 |
+
c1, c2 = st.columns(2)
|
| 78 |
+
with c1:
|
| 79 |
+
effort_val = st.number_input("Effort Levier [N]", value=100, step=1)
|
| 80 |
+
mass_total = st.number_input("Masse Totale (Vélo + Cycliste) [kg]", value=100, step=1)
|
| 81 |
+
wheel_size = st.number_input("Taille de roue [inch]", value=28, step=1)
|
| 82 |
+
with c2:
|
| 83 |
+
speed_kmh = st.number_input("Vitesse du vélo [km/h]", value=25, step=1)
|
| 84 |
+
mass_ratio = st.number_input("Rapport de masse arrière [%]", value=70, step=1, min_value=0, max_value=100)
|
| 85 |
+
|
| 86 |
+
# --- BLOC 2 : DONNÉES COMPOSANTS ---
|
| 87 |
+
with st.expander("⚙️ Données composant", expanded=True):
|
| 88 |
model_list = df['model name'].unique().tolist()
|
| 89 |
+
|
| 90 |
+
col_comp1, col_comp2 = st.columns(2)
|
| 91 |
+
with col_comp1:
|
| 92 |
+
main_model = st.selectbox("Système de freinage étudié", options=model_list)
|
| 93 |
+
with col_comp2:
|
| 94 |
+
comp_options = ["Aucun"] + model_list
|
| 95 |
+
compare_model = st.selectbox("Système de comparaison", options=comp_options)
|
| 96 |
+
|
| 97 |
+
# --- LOGIQUE DE CALCUL (MODÈLE PRINCIPAL) ---
|
| 98 |
+
row = df[df['model name'] == main_model].iloc[0]
|
| 99 |
res_dry = row['dry a'] * effort_val + row['dry b']
|
| 100 |
res_wet = row['wet a'] * effort_val + row['wet b']
|
| 101 |
|
| 102 |
+
# --- LOGIQUE DE CALCUL (MODÈLE COMPARAISON) ---
|
| 103 |
+
res_dry_comp, res_wet_comp = None, None
|
| 104 |
+
if compare_model != "Aucun":
|
| 105 |
+
row_c = df[df['model name'] == compare_model].iloc[0]
|
| 106 |
+
res_dry_comp = row_c['dry a'] * effort_val + row_c['dry b']
|
| 107 |
+
res_wet_comp = row_c['wet a'] * effort_val + row_c['wet b']
|
| 108 |
+
|
| 109 |
+
# --- AFFICHAGE DES RÉSULTATS ---
|
| 110 |
st.write("")
|
| 111 |
+
|
| 112 |
+
# Titre dynamique pour savoir ce qu'on regarde
|
| 113 |
+
if compare_model == "Aucun":
|
| 114 |
+
st.markdown(f"<h3 style='text-align:center;'>Résultats : {main_model}</h3>", unsafe_allow_html=True)
|
| 115 |
+
else:
|
| 116 |
+
st.markdown(f"<h3 style='text-align:center;'>Comparaison : {main_model} vs {compare_model}</h3>", unsafe_allow_html=True)
|
| 117 |
+
|
| 118 |
res_c1, res_c2 = st.columns(2)
|
| 119 |
|
| 120 |
with res_c1:
|
| 121 |
+
st.markdown(f"""<div class="perf-box">
|
| 122 |
+
<p style="font-size: 20px; font-weight: bold; color: #555 !important; margin-bottom:10px;">CONDITION : SEC</p>
|
| 123 |
+
<p class="perf-value">{round(res_dry, 1)} N</p>
|
| 124 |
+
{f'<p style="color:#0082C3; font-weight:bold; margin-top:10px;">vs {round(res_dry_comp, 1)} N</p>' if res_dry_comp else ''}
|
| 125 |
+
</div>""", unsafe_allow_html=True)
|
|
|
|
| 126 |
|
| 127 |
with res_c2:
|
| 128 |
+
st.markdown(f"""<div class="perf-box">
|
| 129 |
+
<p style="font-size: 20px; font-weight: bold; color: #555 !important; margin-bottom:10px;">CONDITION : HUMIDE</p>
|
| 130 |
+
<p class="perf-value" style="color: #E63312 !important;">{round(res_wet, 1)} N</p>
|
| 131 |
+
{f'<p style="color:#E63312; font-weight:bold; margin-top:10px;">vs {round(res_wet_comp, 1)} N</p>' if res_wet_comp else ''}
|
| 132 |
+
</div>""", unsafe_allow_html=True)
|
|
|
|
| 133 |
|
| 134 |
else:
|
| 135 |
+
st.error("Erreur : Fichier Excel manquant.")
|