import streamlit as st import pronotepy from pronotepy import ENTLoginError from pronotepy.ent import * # Importez vos pages ici from pages import accueil, devoirs, notes, edt, contenu, info, vie_scolaire, conv def main(): # Configuration initiale de la page st.set_page_config(page_title="Application Pronote", initial_sidebar_state="collapsed", layout="centered") # Initialiser 'current_page' dans st.session_state if 'current_page' not in st.session_state: st.session_state.current_page = 'accueil' # Définition des options du menu déroulant colleges = { 'Autre': ('', ''), 'Louise Weiss': ('https://0952236p.index-education.net/pronote/eleve.html', 'val_doise'), } cas_options = [ 'Aucune', 'ac_orleans_tours', 'ac_poitiers', 'ac_reunion', 'ac_reims', 'ac_rennes', 'atrium_sud', 'cas_agora06', 'cas_arsene76_edu', 'cas_cybercolleges42_edu', 'cas_kosmos', 'cas_seinesaintdenis_edu', 'eclat_bfc', 'ecollege_haute_garonne_edu', 'ent_94', 'ent_auvergnerhonealpe', 'ent_creuse', 'ent_creuse_educonnect', 'ent_elyco', 'ent_essonne', 'ent_hdf', 'ent_mayotte', 'ent_somme', 'ent_var', 'ent77', 'ent_ecollege78', 'extranet_colleges_somme', 'ile_de_france', 'laclasse_educonnect', 'laclasse_lyon', 'l_normandie', 'lyceeconnecte_aquitaine', 'lyceeconnecte_edu', 'monbureaunumerique', 'neoconnect_guadeloupe', 'occitanie_montpellier', 'occitanie_montpellier_educonnect', 'occitanie_toulouse_edu', 'paris_classe_numerique', 'val_de_marne', 'val_doise' ] if 'client' not in st.session_state or not st.session_state.client.logged_in: # Page de connexion st.title("Connexion à Pronote") college_choice = st.selectbox("🎒 Sélectionnez votre collège", list(colleges.keys())) url, cas_key = colleges[college_choice] if college_choice == 'Autre': url = st.text_input("🧷 URL de Pronote") cas = st.selectbox("📍 CAS", cas_options) else: cas = cas_key username = st.text_input("1️⃣ Identifiant") password = st.text_input("2️⃣ Mot de Passe", type="password") if st.button('Connexion'): try: client = pronotepy.Client(url, username, password, getattr(pronotepy.ent, cas, None)) #client = pronotepy.Client("https://0952236p.index-education.net/pronote/eleve.html", "leny.levant", "Leny15@0", val_doise) if client.logged_in: st.session_state.client = client st.experimental_rerun() else: st.error("Connexion impossible. Veuillez vérifier vos informations.") except ENTLoginError: st.error("Connexion impossible. Vérifiez vos informations de connexion.") else: client = st.session_state.client st.sidebar.title("Navigation") # Navigation page_buttons = { "🏠 Accueil": "accueil", "📅 Emploi du temps": "edt", "📚 Devoirs": "devoirs", "📝 Notes": "notes", "📧 Messagerie": "conv", "i️ Informations": "info", "🕒 Vie Scolaire": "vie_scolaire" } for button_label, page_name in page_buttons.items(): if st.sidebar.button(button_label, key=page_name, use_container_width=True): st.session_state.current_page = page_name st.rerun() # Force le rechargement de l'application avec le nouvel état if 'current_page' not in st.session_state: st.session_state.current_page = 'accueil' # Défaut à accueil si non défini # Affichage conditionnel basé sur la page actuelle if st.session_state.current_page == 'accueil': accueil.app(client) elif st.session_state.current_page == 'devoirs': devoirs.app(client) elif st.session_state.current_page == 'notes': notes.app(client) elif st.session_state.current_page == 'edt': edt.app(client) elif st.session_state.current_page == 'contenu': contenu.show_lesson_content() elif st.session_state.current_page == 'info': info.app(client) elif st.session_state.current_page == 'vie_scolaire': vie_scolaire.app(client) elif st.session_state.current_page == 'conv': conv.app(client) if st.sidebar.button('🚪 Déconnexion'): del st.session_state.client del st.session_state.current_page st.rerun() if __name__ == "__main__": main()