IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

GUI Python Discussion :

generer un bulletin scolaire pour lycee python tkinter


Sujet :

GUI Python

  1. #1
    Nouveau Candidat au Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mai 2024
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Enseignement

    Informations forums :
    Inscription : Mai 2024
    Messages : 7
    Points : 0
    Points
    0
    Par défaut generer un bulletin scolaire pour lycee python tkinter
    Bonjour a toute la communaute developpez.net, svp je voudrais savoir comment generer(un exemple de code si possible) un bulletin scolaire pour lyceen avec python tkinter jai deja pu enregistrer les eleves,enseignants,les trimestres,les matieres,les classes et les notes. Comment faire avoir un bulletin appartir de cela. Merci d'avance a vous.

  2. #2
    Expert éminent
    Avatar de fred1599
    Homme Profil pro
    Lead Dev Python
    Inscrit en
    Juillet 2006
    Messages
    3 885
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations professionnelles :
    Activité : Lead Dev Python
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Juillet 2006
    Messages : 3 885
    Points : 7 233
    Points
    7 233
    Par défaut
    Bonjour,

    Citation Envoyé par dylois
    jai deja pu enregistrer les eleves,enseignants,les trimestres,les matieres,les classes et les notes
    Sous quel format avait vous fait cet enregistrement ?

    Citation Envoyé par dylois
    je voudrais savoir comment generer(un exemple de code si possible) un bulletin scolaire pour lyceen avec python tkinter
    Qu'appelez vous générer ? Voulez vous afficher le bulletin scolaire sous le format d'une interface graphique comme Tkinter ?

    Peut-être que vous pourriez proposer un exemple visuel de ce que vous souhaitez ?
    Celui qui trouve sans chercher est celui qui a longtemps cherché sans trouver.(Bachelard)
    La connaissance s'acquiert par l'expérience, tout le reste n'est que de l'information.(Einstein)

  3. #3
    Nouveau Candidat au Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mai 2024
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Enseignement

    Informations forums :
    Inscription : Mai 2024
    Messages : 7
    Points : 0
    Points
    0
    Par défaut generer un bulletion scolaire pour lyceen avec python tkinter
    jai une bd "ecole.db" les tables eleves(id_el,nom,classe),enseignant(id_ensei,nom),note(id_note,annee,nom_enseignant,nom_classe,nom_trimestre,nom_matiere,coef,note),matiere(id_mat,nom_matiere,coef,nom_enseignant),trimestre(id_tri,nom_trimestre),classe(id_classe,nom_classe),etablissement(id_eta,nom_eta,adresse,tel,logo),annee(id_annee,annee) toutes les tables sont remplis et peuvent etre modifier ou supprimer. le probleme ke j rencontre est de generer le bulletin. par quoi dois-je commencer, quel sont les bibliotheque necessaire

  4. #4
    Expert éminent
    Avatar de fred1599
    Homme Profil pro
    Lead Dev Python
    Inscrit en
    Juillet 2006
    Messages
    3 885
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations professionnelles :
    Activité : Lead Dev Python
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Juillet 2006
    Messages : 3 885
    Points : 7 233
    Points
    7 233
    Par défaut
    Bonjour,

    Citation Envoyé par dylois
    jai une bd "ecole.db" les tables eleves(id_el,nom,classe),enseignant(id_ensei,nom),note(id_note,annee,nom_enseignant,nom_classe,nom_trimestre,nom_matiere,coef,note),matiere(id_mat,nom_matiere,coef,nom_enseignant),trimestre(id_tri,nom_trimestre),classe(id_classe,nom_classe),etablissement(id_eta,nom_eta,adresse,tel,logo),annee(id_annee,annee) toutes les tables sont remplis et peuvent etre modifier ou supprimer. le probleme ke j rencontre est de generer le bulletin. par quoi dois-je commencer, quel sont les bibliotheque necessaire
    Vous répétez la même question, mais vous ne répondez aux miennes qui demandent d'exprimer et préciser ce que vous appelez "générer".
    Celui qui trouve sans chercher est celui qui a longtemps cherché sans trouver.(Bachelard)
    La connaissance s'acquiert par l'expérience, tout le reste n'est que de l'information.(Einstein)

  5. #5
    Expert confirmé Avatar de papajoker
    Homme Profil pro
    Développeur Web
    Inscrit en
    Septembre 2013
    Messages
    2 195
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Nièvre (Bourgogne)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Septembre 2013
    Messages : 2 195
    Points : 4 648
    Points
    4 648
    Par défaut
    bonjour

    et oui, on tourne en rond

    Il faut surtout que tu saches quoi faire de ce "bulletin"
    - on peut générer une sortie écran (dans tkinter)
    - on peut générer un fichier (texte, pdf, html, ...)
    - et bien autres

    La première chose est de faire "une" requete sql pour obtenir toutes les données que tu vas "afficher".
    ps: tu dois bien déjà faire quelques requetes sql pour afficher des choses dans TK ? ici, c'est juste une requete (un peu) plus compliquée.
    Puisque tu nous montres que tes tables, je suppose que tu n'as même pas commencé ta requete Si oui, alors aucune raison de passer à la suite pour l'instant.
    ps: nous n'aidons pas à faire des requetes sql dans le forum python, existe ici un forum dédié.


    une fois que tu as les données. Il reste à les entrer dans un format particulier pour afficher le résultat de la requête (faire des print() ? ou afficher dans une fenetre tk ?)

    Citation Envoyé par dylois Voir le message
    quel sont les bibliotheque necessaire
    Pour interroger ta base de données : la bibliothèque de ta base de donnée
    Pour une sortie dans ton interface graphique : tkinter
    Pour une sortie en pdf, une librairie pdf
    Pour une sortie excel, sans doute une librairie excel
    Pour une sortie texte, peut-être une bibliotèque du type jinja
    ...
    $moi= ( !== ) ? : ;

  6. #6
    Nouveau Candidat au Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mai 2024
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Enseignement

    Informations forums :
    Inscription : Mai 2024
    Messages : 7
    Points : 0
    Points
    0
    Par défaut bonjour bonjour fred
    j me debrouille pour y arriver mais c pas encore au point, entre temps voila cke jai pu faire
    import tkinter as tk
    from tkinter import ttk
    import pymysql
    from tkinter import messagebox
    import fpdf

    # Database connection
    maBase = pymysql.connect(host="localhost", user="root", password="", database="ecoledb")
    cursor = maBase.cursor()
    subject_info = None
    average= None
    appreciation = None

    # Function to retrieve student information
    def get_student_info(student_id):
    cursor.execute('SELECT nom, classe FROM eleve WHERE matricule = %s', (student_id,))
    student_info = cursor.fetchone()
    if student_info:
    return student_info[0], student_info[1]
    else:
    return None, None

    # Function to retrieve school information
    def get_school_info():
    cursor.execute('SELECT nom,tutelle FROM etablissement')
    school_info = cursor.fetchone()
    if school_info:
    return school_info[0], school_info[1]
    else:
    return None, None

    # Function to retrieve subject information for a specific student
    def get_subject_info(student_id, year, trimester):
    cursor.execute("""
    SELECT matiere.nom, enseignant.nom AS nom_enseignant, note.note, matiere.coef
    FROM note
    JOIN matiere ON note.matiere = matiere.mid
    JOIN enseignant ON note.professeur = enseignant.enid
    WHERE note.matricule = %s AND note.annee = %s AND note.periode = %s
    """, (student_id, year, trimester))
    subject_info = cursor.fetchall()
    return subject_info

    # Function to calculate final grade and average
    def calculate_grades(subject_info):
    total_marks = 0
    total_coefficients = 0
    for subject in subject_info:
    total_marks += subject[2] * subject[3]
    total_coefficients += subject[3]

    if total_coefficients != 0:
    average = total_marks / total_coefficients
    else:
    average = 0

    return average

    # Function to generate appreciation based on average score
    def generate_appreciation(average):
    if average >= 90:
    appreciation = "Excellent"
    elif average >= 80:
    appreciation = "Très Bien"
    elif average >= 70:
    appreciation = "Bien"
    elif average >= 60:
    appreciation = "Assez Bien"
    else:
    appreciation = "Passable"

    return appreciation

    # Function to generate bulletin PDF report
    def generate_bulletin_pdf(school_info,student_info,subject_info,average,appreciation):
    # Create PDF object
    pdf = fpdf.FPDF()

    # Set PDF properties
    pdf.add_page()
    pdf.set_font('Arial', 'B', 16) # Set font to Arial Bold 16

    # Add school logo (if available)
    if school_info[1]:
    with open(school_info[1], 'rb') as logo_file:
    logo_data = logo_file.read()
    pdf.image(logo_data, x=10, y=10, w=30, h=30)

    # Add school name and student information
    pdf.set_y(40) # Set y-position for school name
    pdf.cell(0, 10, school_info[0], align='C') # Print school name centered

    pdf.set_y(50) # Set y-position for student information
    pdf.set_font('Arial', '', 12) # Change font to Arial Regular 12
    pdf.cell(40, 10, "Nom:", align='L')
    pdf.cell(60, 10, student_info[0], align='L')
    pdf.cell(40, 10, "Classe:", align='L')
    pdf.cell(0, 10, student_info[1], align='L')

    # Add table header for subject information
    pdf.set_y(70) # Set y-position for table header
    pdf.set_font('Arial', 'B', 10) # Set font to Arial Bold 10
    pdf.cell(60, 10, "Matière", align='C')
    pdf.cell(40, 10, "Enseignant", align='C')
    pdf.cell(20, 10, "Note", align='C')
    pdf.cell(20, 10, "Coeff.", align='C')
    pdf.cell(40, 10, "Note Finale", align='C')
    pdf.ln(10) # Add line break after header

    # Add subject information with lines
    pdf.set_font('Arial', '', 10) # Set font to Arial Regular 10
    for subject in subject_info:
    pdf.cell(60, 10, subject[0], align='L')
    pdf.cell(40, 10, subject[1], align='L')
    pdf.cell(20, 10, str(subject[2]), align='C')
    pdf.cell(20, 10, str(subject[3]), align='C')
    # Calculate and display final grade (Note * Coeff)
    final_grade = subject[2] * subject[3]
    pdf.cell(40, 10, str(final_grade), align='C')
    pdf.ln(10) # Add line break after each subject

    # Add average and appreciation
    pdf.set_font('Arial', 'B', 12) # Set font to Arial Bold 12
    pdf.cell(80, 10, "Moyenne :", align='L')
    pdf.cell(0, 10, str(average), align='L')

    pdf.set_y(pdf.get_y() + 10) # Move down a bit
    pdf.cell(80, 10, "Appréciation :", align='L')
    pdf.cell(0, 10, appreciation, align='L')

    # Add signature lines (optional)
    # You can uncomment and modify these lines to add signature areas
    # pdf.set_y(pdf.get_y() + 50)
    # pdf.cell(0, 10, "Signature du Chef d'Établissement

    # Main application window
    window = tk.Tk()
    window.title("Gestion des Bulletins Scolaires")

    # Frame for student selection
    student_frame = tk.Frame(window)
    student_frame.pack(pady=10)

    student_id_label = tk.Label(student_frame, text="ID Élève:")
    student_id_label.pack(side=tk.LEFT, padx=5)

    student_id_entry = tk.Entry(student_frame)
    student_id_entry.pack(side=tk.LEFT, padx=5)

    select_student_button = tk.Button(student_frame, text="Sélectionner Élève", command=lambda: get_student_data())
    select_student_button.pack(side=tk.LEFT, padx=5)

    # Frame for student information display
    student_info_frame = tk.Frame(window)
    student_info_frame.pack(pady=10)

    student_name_label = tk.Label(student_info_frame, text="Nom:")
    student_name_label.pack(side=tk.LEFT, padx=5)

    student_name_value = tk.Label(student_info_frame, text="")
    student_name_value.pack(side=tk.LEFT, padx=5)

    student_class_label = tk.Label(student_info_frame, text="Classe:")
    student_class_label.pack(side=tk.LEFT, padx=5)

    student_class_value = tk.Label(student_info_frame, text="")
    student_class_value.pack(side=tk.LEFT, padx=5)

    # Frame for school information display
    school_info_frame = tk.Frame(window)
    school_info_frame.pack(pady=10)

    school_name_label = tk.Label(school_info_frame, text="Établissement:")
    school_name_label.pack(side=tk.LEFT, padx=5)

    school_name_value = tk.Label(school_info_frame, text="")
    school_name_value.pack(side=tk.LEFT, padx=5)

    # Frame for subject information display
    subject_info_frame = tk.Frame(window, bd=1, relief=tk.SUNKEN)
    subject_info_frame.pack(pady=10)

    subject_tree = ttk.Treeview(subject_info_frame, columns=("Matière", "Enseignant", "Note", "Coefficient", "Note Finale"))
    subject_tree.heading("Matière", text="Matière")
    subject_tree.heading("Enseignant", text="Enseignant")
    subject_tree.heading("Note", text="Note")
    subject_tree.heading("Coefficient", text="Coefficient")
    subject_tree.heading("Note Finale", text="Note Finale")
    subject_tree.pack()

    # Frame for average and appreciation display
    average_frame = tk.Frame(window)
    average_frame.pack(pady=10)

    average_label = tk.Label(average_frame, text="Moyenne:")
    average_label.pack(side=tk.LEFT, padx=5)

    average_value = tk.Label(average_frame, text="")
    average_value.pack(side=tk.LEFT, padx=5)

    appreciation_label = tk.Label(average_frame, text="Appréciation:")
    appreciation_label.pack(side=tk.LEFT, padx=5)

    appreciation_value = tk.Label(average_frame, text="")
    appreciation_value.pack(side=tk.LEFT, padx=5)

    # Frame for signature and generation buttons
    signature_frame = tk.Frame(window)
    signature_frame.pack(pady=10)

    principal_signature_label = tk.Label(signature_frame, text="Signature du Chef d'Établissement:")
    principal_signature_label.pack(side=tk.LEFT, padx=5)

    principal_signature_entry = tk.Entry(signature_frame)
    principal_signature_entry.pack(side=tk.LEFT, padx=5)

    guardian_signature_label = tk.Label(signature_frame, text="Signature du Tuteur:")
    guardian_signature_label.pack(side=tk.LEFT, padx=5)

    guardian_signature_entry = tk.Entry(signature_frame)
    guardian_signature_entry.pack(side=tk.LEFT, padx=5)

    generate_button = tk.Button(signature_frame, text="Générer Bulletin", command=lambda: generate_bulletin())
    generate_button.pack(pady=5)

    # Function to retrieve and display student data
    def get_student_data():
    student_id = student_id_entry.get()
    if student_id:
    try:
    student_id = int(student_id)
    except ValueError:
    messagebox.showerror("Erreur", "ID Élève invalide.")
    return

    student_name, student_class = get_student_info(student_id)
    if student_name and student_class:
    student_name_value.config(text=student_name)
    student_class_value.config(text=student_class)

    school_name, school_logo = get_school_info()
    if school_name and school_logo:
    school_name_value.config(text=school_name)

    subject_info = get_subject_info(student_id, 2024, 1) # Replace with actual year and trimester
    if subject_info:
    subject_tree.delete(*subject_tree.get_children())
    for subject in subject_info:
    subject_tree.insert("", tk.END, values=subject)

    average = calculate_grades(subject_info)
    appreciation = generate_appreciation(average)

    average_value.config(text=f"{average:.2f}")
    appreciation_value.config(text=appreciation)

    def generate_bulletin(subject_info, average, appreciation):

    # Retrieve data from labels and entries
    student_name = student_name_value.cget("text")
    student_class = student_class_value.cget("text")
    school_name = school_name_value.cget("text")
    principal_signature = principal_signature_entry.get()
    guardian_signature = guardian_signature_entry.get()

    # Generate PDF report using the retrieved data
    generate_bulletin_pdf(
    student_name, student_class, school_name,subject_info, average, appreciation,
    principal_signature, guardian_signature
    )

    # Main event loop
    window.mainloop()

    mais le resultat ne suit pas
    ni la forme ni le contenu comme jesper

  7. #7
    Nouveau Candidat au Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mai 2024
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Enseignement

    Informations forums :
    Inscription : Mai 2024
    Messages : 7
    Points : 0
    Points
    0
    Par défaut
    j voudrais generer le bulletin sous pdf si possible avec canvas() en entrant l'id de l'eleve,l'annee,le trimestre, la classe

  8. #8
    Membre chevronné
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Février 2003
    Messages
    1 582
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Industrie

    Informations forums :
    Inscription : Février 2003
    Messages : 1 582
    Points : 2 030
    Points
    2 030
    Par défaut
    Cliquez sur le lien de ma signature afin de savoir comment publier votre code plus proprement.

    L'indentation étant d'une importance capitale en Python, vous comprendrez que là...

  9. #9
    Nouveau Candidat au Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mai 2024
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Enseignement

    Informations forums :
    Inscription : Mai 2024
    Messages : 7
    Points : 0
    Points
    0
    Par défaut
    bonjour bonjour une fois de plus merci d'avance pour l'attention
    [import tkinter as tk
    from tkinter import ttk
    import pymysql
    from tkinter import messagebox
    import fpdf

    # Database connection
    maBase = pymysql.connect(host="localhost", user="root", password="", database="ecoledb")
    cursor = maBase.cursor()
    subject_info = None
    average= None
    appreciation = None

    # Function to retrieve student information
    def get_student_info(student_id):
    cursor.execute('SELECT nom, classe FROM eleve WHERE matricule = %s', (student_id,))
    student_info = cursor.fetchone()
    if student_info:
    return student_info[0], student_info[1]
    else:
    return None, None

    # Function to retrieve school information
    def get_school_info():
    cursor.execute('SELECT nom,tutelle FROM etablissement')
    school_info = cursor.fetchone()
    if school_info:
    return school_info[0], school_info[1]
    else:
    return None, None

    # Function to retrieve subject information for a specific student
    def get_subject_info(student_id, year, trimester):
    cursor.execute("""
    SELECT matiere.nom, enseignant.nom AS nom_enseignant, note.note, matiere.coef
    FROM note
    JOIN matiere ON note.matiere = matiere.mid
    JOIN enseignant ON note.professeur = enseignant.enid
    WHERE note.matricule = %s AND note.annee = %s AND note.periode = %s
    """, (student_id, year, trimester))
    subject_info = cursor.fetchall()
    return subject_info

    # Function to calculate final grade and average
    def calculate_grades(subject_info):
    total_marks = 0
    total_coefficients = 0
    for subject in subject_info:
    total_marks += subject[2] * subject[3]
    total_coefficients += subject[3]

    if total_coefficients != 0:
    average = total_marks / total_coefficients
    else:
    average = 0

    return average

    # Function to generate appreciation based on average score
    def generate_appreciation(average):
    if average >= 90:
    appreciation = "Excellent"
    elif average >= 80:
    appreciation = "Très Bien"
    elif average >= 70:
    appreciation = "Bien"
    elif average >= 60:
    appreciation = "Assez Bien"
    else:
    appreciation = "Passable"

    return appreciation

    # Function to generate bulletin PDF report
    def generate_bulletin_pdf(school_info,student_info,subject_info,average,appreciation):
    # Create PDF object
    pdf = fpdf.FPDF()

    # Set PDF properties
    pdf.add_page()
    pdf.set_font('Arial', 'B', 16) # Set font to Arial Bold 16

    # Add school logo (if available)
    if school_info[1]:
    with open(school_info[1], 'rb') as logo_file:
    logo_data = logo_file.read()
    pdf.image(logo_data, x=10, y=10, w=30, h=30)

    # Add school name and student information
    pdf.set_y(40) # Set y-position for school name
    pdf.cell(0, 10, school_info[0], align='C') # Print school name centered

    pdf.set_y(50) # Set y-position for student information
    pdf.set_font('Arial', '', 12) # Change font to Arial Regular 12
    pdf.cell(40, 10, "Nom:", align='L')
    pdf.cell(60, 10, student_info[0], align='L')
    pdf.cell(40, 10, "Classe:", align='L')
    pdf.cell(0, 10, student_info[1], align='L')

    # Add table header for subject information
    pdf.set_y(70) # Set y-position for table header
    pdf.set_font('Arial', 'B', 10) # Set font to Arial Bold 10
    pdf.cell(60, 10, "Matière", align='C')
    pdf.cell(40, 10, "Enseignant", align='C')
    pdf.cell(20, 10, "Note", align='C')
    pdf.cell(20, 10, "Coeff.", align='C')
    pdf.cell(40, 10, "Note Finale", align='C')
    pdf.ln(10) # Add line break after header

    # Add subject information with lines
    pdf.set_font('Arial', '', 10) # Set font to Arial Regular 10
    for subject in subject_info:
    pdf.cell(60, 10, subject[0], align='L')
    pdf.cell(40, 10, subject[1], align='L')
    pdf.cell(20, 10, str(subject[2]), align='C')
    pdf.cell(20, 10, str(subject[3]), align='C')
    # Calculate and display final grade (Note * Coeff)
    final_grade = subject[2] * subject[3]
    pdf.cell(40, 10, str(final_grade), align='C')
    pdf.ln(10) # Add line break after each subject

    # Add average and appreciation
    pdf.set_font('Arial', 'B', 12) # Set font to Arial Bold 12
    pdf.cell(80, 10, "Moyenne :", align='L')
    pdf.cell(0, 10, str(average), align='L')

    pdf.set_y(pdf.get_y() + 10) # Move down a bit
    pdf.cell(80, 10, "Appréciation :", align='L')
    pdf.cell(0, 10, appreciation, align='L')

    # Add signature lines (optional)
    # You can uncomment and modify these lines to add signature areas
    # pdf.set_y(pdf.get_y() + 50)
    # pdf.cell(0, 10, "Signature du Chef d'Établissement

    # Main application window
    window = tk.Tk()
    window.title("Gestion des Bulletins Scolaires")

    # Frame for student selection
    student_frame = tk.Frame(window)
    student_frame.pack(pady=10)

    student_id_label = tk.Label(student_frame, text="ID Élève:")
    student_id_label.pack(side=tk.LEFT, padx=5)

    student_id_entry = tk.Entry(student_frame)
    student_id_entry.pack(side=tk.LEFT, padx=5)

    select_student_button = tk.Button(student_frame, text="Sélectionner Élève", command=lambda: get_student_data())
    select_student_button.pack(side=tk.LEFT, padx=5)

    # Frame for student information display
    student_info_frame = tk.Frame(window)
    student_info_frame.pack(pady=10)

    student_name_label = tk.Label(student_info_frame, text="Nom:")
    student_name_label.pack(side=tk.LEFT, padx=5)

    student_name_value = tk.Label(student_info_frame, text="")
    student_name_value.pack(side=tk.LEFT, padx=5)

    student_class_label = tk.Label(student_info_frame, text="Classe:")
    student_class_label.pack(side=tk.LEFT, padx=5)

    student_class_value = tk.Label(student_info_frame, text="")
    student_class_value.pack(side=tk.LEFT, padx=5)

    # Frame for school information display
    school_info_frame = tk.Frame(window)
    school_info_frame.pack(pady=10)

    school_name_label = tk.Label(school_info_frame, text="Établissement:")
    school_name_label.pack(side=tk.LEFT, padx=5)

    school_name_value = tk.Label(school_info_frame, text="")
    school_name_value.pack(side=tk.LEFT, padx=5)

    # Frame for subject information display
    subject_info_frame = tk.Frame(window, bd=1, relief=tk.SUNKEN)
    subject_info_frame.pack(pady=10)

    subject_tree = ttk.Treeview(subject_info_frame, columns=("Matière", "Enseignant", "Note", "Coefficient", "Note Finale"))
    subject_tree.heading("Matière", text="Matière")
    subject_tree.heading("Enseignant", text="Enseignant")
    subject_tree.heading("Note", text="Note")
    subject_tree.heading("Coefficient", text="Coefficient")
    subject_tree.heading("Note Finale", text="Note Finale")
    subject_tree.pack()

    # Frame for average and appreciation display
    average_frame = tk.Frame(window)
    average_frame.pack(pady=10)

    average_label = tk.Label(average_frame, text="Moyenne:")
    average_label.pack(side=tk.LEFT, padx=5)

    average_value = tk.Label(average_frame, text="")
    average_value.pack(side=tk.LEFT, padx=5)

    appreciation_label = tk.Label(average_frame, text="Appréciation:")
    appreciation_label.pack(side=tk.LEFT, padx=5)

    appreciation_value = tk.Label(average_frame, text="")
    appreciation_value.pack(side=tk.LEFT, padx=5)

    # Frame for signature and generation buttons
    signature_frame = tk.Frame(window)
    signature_frame.pack(pady=10)

    principal_signature_label = tk.Label(signature_frame, text="Signature du Chef d'Établissement:")
    principal_signature_label.pack(side=tk.LEFT, padx=5)

    principal_signature_entry = tk.Entry(signature_frame)
    principal_signature_entry.pack(side=tk.LEFT, padx=5)

    guardian_signature_label = tk.Label(signature_frame, text="Signature du Tuteur:")
    guardian_signature_label.pack(side=tk.LEFT, padx=5)

    guardian_signature_entry = tk.Entry(signature_frame)
    guardian_signature_entry.pack(side=tk.LEFT, padx=5)

    generate_button = tk.Button(signature_frame, text="Générer Bulletin", command=lambda: generate_bulletin())
    generate_button.pack(pady=5)

    # Function to retrieve and display student data
    def get_student_data():
    student_id = student_id_entry.get()
    if student_id:
    try:
    student_id = int(student_id)
    except ValueError:
    messagebox.showerror("Erreur", "ID Élève invalide.")
    return

    student_name, student_class = get_student_info(student_id)
    if student_name and student_class:
    student_name_value.config(text=student_name)
    student_class_value.config(text=student_class)

    school_name, school_logo = get_school_info()
    if school_name and school_logo:
    school_name_value.config(text=school_name)

    subject_info = get_subject_info(student_id, 2024, 1) # Replace with actual year and trimester
    if subject_info:
    subject_tree.delete(*subject_tree.get_children())
    for subject in subject_info:
    subject_tree.insert("", tk.END, values=subject)

    average = calculate_grades(subject_info)
    appreciation = generate_appreciation(average)

    average_value.config(text=f"{average:.2f}")
    appreciation_value.config(text=appreciation)

    def generate_bulletin(subject_info, average, appreciation):

    # Retrieve data from labels and entries
    student_name = student_name_value.cget("text")
    student_class = student_class_value.cget("text")
    school_name = school_name_value.cget("text")
    principal_signature = principal_signature_entry.get()
    guardian_signature = guardian_signature_entry.get()

    # Generate PDF report using the retrieved data
    generate_bulletin_pdf(
    student_name, student_class, school_name,subject_info, average, appreciation,
    principal_signature, guardian_signature
    )

    # Main event loop
    window.mainloop()]
    [/CODE]

  10. #10
    Membre chevronné
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Février 2003
    Messages
    1 582
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Industrie

    Informations forums :
    Inscription : Février 2003
    Messages : 1 582
    Points : 2 030
    Points
    2 030
    Par défaut
    Toujours pas

  11. #11
    Expert confirmé Avatar de papajoker
    Homme Profil pro
    Développeur Web
    Inscrit en
    Septembre 2013
    Messages
    2 195
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Nièvre (Bourgogne)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Septembre 2013
    Messages : 2 195
    Points : 4 648
    Points
    4 648
    Par défaut
    Réédite ton message #9, pas la peine d'en créer 36 (non lisibles) !!!

    Bouton à droite dans la barre d'outils#.
    note: tu as un bouton "prévisualiser"

    Citation Envoyé par dylois Voir le message
    mais le resultat ne suit pas
    ni la forme ni le contenu comme jesper
    Nous n'avons pas ta base de donnée et puisque le code est illisible, tu ne nous donnes même pas une chance de t'aider
    Un minimum est de nous dire exactement ce qui ne va pas ! Ici tu es tellement flou que tu fais tout pour ne pas avoir d'aide...

    "resultat ne suit pas" ? Je ne suis même pas sûr de comprendre ... Comme écrit plus haut, Avant de penser au pdf, il faut déjà valider tes requetes sql : afficher le résultat dans la console est un minimum.
    $moi= ( !== ) ? : ;

  12. #12
    Nouveau Candidat au Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mai 2024
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Enseignement

    Informations forums :
    Inscription : Mai 2024
    Messages : 7
    Points : 0
    Points
    0
    Par défaut generer un bulletin scolaire pour lyceen
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    import tkinter as tk
    from tkinter import ttk
    import pymysql
    from tkinter import messagebox
    import fpdf
     
    # Database connection
    maBase = pymysql.connect(host="localhost", user="root", password="", database="ecoledb")
    cursor = maBase.cursor()
    subject_info = None
    average= None
    appreciation = None
     
    # Function to retrieve student information
    def get_student_info(student_id):
    cursor.execute('SELECT nom, classe FROM eleve WHERE matricule = %s', (student_id,))
    student_info = cursor.fetchone()
    if student_info:
    return student_info[0], student_info[1]
    else:
    return None, None
     
    # Function to retrieve school information
    def get_school_info():
    cursor.execute('SELECT nom,tutelle FROM etablissement')
    school_info = cursor.fetchone()
    if school_info:
    return school_info[0], school_info[1]
    else:
    return None, None
     
    # Function to retrieve subject information for a specific student
    def get_subject_info(student_id, year, trimester):
    cursor.execute("""
    SELECT matiere.nom, enseignant.nom AS nom_enseignant, note.note, matiere.coef
    FROM note
    JOIN matiere ON note.matiere = matiere.mid
    JOIN enseignant ON note.professeur = enseignant.enid
    WHERE note.matricule = %s AND note.annee = %s AND note.periode = %s
    """, (student_id, year, trimester))
    subject_info = cursor.fetchall()
    return subject_info
     
    # Function to calculate final grade and average
    def calculate_grades(subject_info):
    total_marks = 0
    total_coefficients = 0
    for subject in subject_info:
    total_marks += subject[2] * subject[3]
    total_coefficients += subject[3]
     
    if total_coefficients != 0:
    average = total_marks / total_coefficients
    else:
    average = 0
     
    return average
     
    # Function to generate appreciation based on average score
    def generate_appreciation(average):
    if average >= 90:
    appreciation = "Excellent"
    elif average >= 80:
    appreciation = "Très Bien"
    elif average >= 70:
    appreciation = "Bien"
    elif average >= 60:
    appreciation = "Assez Bien"
    else:
    appreciation = "Passable"
     
    return appreciation
     
    # Function to generate bulletin PDF report
    def generate_bulletin_pdf(school_info,student_info,subject_info,average,appreciation):
    # Create PDF object
    pdf = fpdf.FPDF()
     
    # Set PDF properties
    pdf.add_page()
    pdf.set_font('Arial', 'B', 16) # Set font to Arial Bold 16
     
    # Add school logo (if available)
    if school_info[1]:
    with open(school_info[1], 'rb') as logo_file:
    logo_data = logo_file.read()
    pdf.image(logo_data, x=10, y=10, w=30, h=30)
     
    # Add school name and student information
    pdf.set_y(40) # Set y-position for school name
    pdf.cell(0, 10, school_info[0], align='C') # Print school name centered
     
    pdf.set_y(50) # Set y-position for student information
    pdf.set_font('Arial', '', 12) # Change font to Arial Regular 12
    pdf.cell(40, 10, "Nom:", align='L')
    pdf.cell(60, 10, student_info[0], align='L')
    pdf.cell(40, 10, "Classe:", align='L')
    pdf.cell(0, 10, student_info[1], align='L')
     
    # Add table header for subject information
    pdf.set_y(70) # Set y-position for table header
    pdf.set_font('Arial', 'B', 10) # Set font to Arial Bold 10
    pdf.cell(60, 10, "Matière", align='C')
    pdf.cell(40, 10, "Enseignant", align='C')
    pdf.cell(20, 10, "Note", align='C')
    pdf.cell(20, 10, "Coeff.", align='C')
    pdf.cell(40, 10, "Note Finale", align='C')
    pdf.ln(10) # Add line break after header
     
    # Add subject information with lines
    pdf.set_font('Arial', '', 10) # Set font to Arial Regular 10
    for subject in subject_info:
    pdf.cell(60, 10, subject[0], align='L')
    pdf.cell(40, 10, subject[1], align='L')
    pdf.cell(20, 10, str(subject[2]), align='C')
    pdf.cell(20, 10, str(subject[3]), align='C')
    # Calculate and display final grade (Note * Coeff)
    final_grade = subject[2] * subject[3]
    pdf.cell(40, 10, str(final_grade), align='C')
    pdf.ln(10) # Add line break after each subject
     
    # Add average and appreciation
    pdf.set_font('Arial', 'B', 12) # Set font to Arial Bold 12
    pdf.cell(80, 10, "Moyenne :", align='L')
    pdf.cell(0, 10, str(average), align='L')
     
    pdf.set_y(pdf.get_y() + 10) # Move down a bit
    pdf.cell(80, 10, "Appréciation :", align='L')
    pdf.cell(0, 10, appreciation, align='L')
     
    # Add signature lines (optional)
    # You can uncomment and modify these lines to add signature areas
    # pdf.set_y(pdf.get_y() + 50)
    # pdf.cell(0, 10, "Signature du Chef d'Établissement
     
    # Main application window
    window = tk.Tk()
    window.title("Gestion des Bulletins Scolaires")
     
    # Frame for student selection
    student_frame = tk.Frame(window)
    student_frame.pack(pady=10)
     
    student_id_label = tk.Label(student_frame, text="ID Élève:")
    student_id_label.pack(side=tk.LEFT, padx=5)
     
    student_id_entry = tk.Entry(student_frame)
    student_id_entry.pack(side=tk.LEFT, padx=5)
     
    select_student_button = tk.Button(student_frame, text="Sélectionner Élève", command=lambda: get_student_data())
    select_student_button.pack(side=tk.LEFT, padx=5)
     
    # Frame for student information display
    student_info_frame = tk.Frame(window)
    student_info_frame.pack(pady=10)
     
    student_name_label = tk.Label(student_info_frame, text="Nom:")
    student_name_label.pack(side=tk.LEFT, padx=5)
     
    student_name_value = tk.Label(student_info_frame, text="")
    student_name_value.pack(side=tk.LEFT, padx=5)
     
    student_class_label = tk.Label(student_info_frame, text="Classe:")
    student_class_label.pack(side=tk.LEFT, padx=5)
     
    student_class_value = tk.Label(student_info_frame, text="")
    student_class_value.pack(side=tk.LEFT, padx=5)
     
    # Frame for school information display
    school_info_frame = tk.Frame(window)
    school_info_frame.pack(pady=10)
     
    school_name_label = tk.Label(school_info_frame, text="Établissement:")
    school_name_label.pack(side=tk.LEFT, padx=5)
     
    school_name_value = tk.Label(school_info_frame, text="")
    school_name_value.pack(side=tk.LEFT, padx=5)
     
    # Frame for subject information display
    subject_info_frame = tk.Frame(window, bd=1, relief=tk.SUNKEN)
    subject_info_frame.pack(pady=10)
     
    subject_tree = ttk.Treeview(subject_info_frame, columns=("Matière", "Enseignant", "Note", "Coefficient", "Note Finale"))
    subject_tree.heading("Matière", text="Matière")
    subject_tree.heading("Enseignant", text="Enseignant")
    subject_tree.heading("Note", text="Note")
    subject_tree.heading("Coefficient", text="Coefficient")
    subject_tree.heading("Note Finale", text="Note Finale")
    subject_tree.pack()
     
    # Frame for average and appreciation display
    average_frame = tk.Frame(window)
    average_frame.pack(pady=10)
     
    average_label = tk.Label(average_frame, text="Moyenne:")
    average_label.pack(side=tk.LEFT, padx=5)
     
    average_value = tk.Label(average_frame, text="")
    average_value.pack(side=tk.LEFT, padx=5)
     
    appreciation_label = tk.Label(average_frame, text="Appréciation:")
    appreciation_label.pack(side=tk.LEFT, padx=5)
     
    appreciation_value = tk.Label(average_frame, text="")
    appreciation_value.pack(side=tk.LEFT, padx=5)
     
    # Frame for signature and generation buttons
    signature_frame = tk.Frame(window)
    signature_frame.pack(pady=10)
     
    principal_signature_label = tk.Label(signature_frame, text="Signature du Chef d'Établissement:")
    principal_signature_label.pack(side=tk.LEFT, padx=5)
     
    principal_signature_entry = tk.Entry(signature_frame)
    principal_signature_entry.pack(side=tk.LEFT, padx=5)
     
    guardian_signature_label = tk.Label(signature_frame, text="Signature du Tuteur:")
    guardian_signature_label.pack(side=tk.LEFT, padx=5)
     
    guardian_signature_entry = tk.Entry(signature_frame)
    guardian_signature_entry.pack(side=tk.LEFT, padx=5)
     
    generate_button = tk.Button(signature_frame, text="Générer Bulletin", command=lambda: generate_bulletin())
    generate_button.pack(pady=5)
     
    # Function to retrieve and display student data
    def get_student_data():
    student_id = student_id_entry.get()
    if student_id:
    try:
    student_id = int(student_id)
    except ValueError:
    messagebox.showerror("Erreur", "ID Élève invalide.")
    return
     
    student_name, student_class = get_student_info(student_id)
    if student_name and student_class:
    student_name_value.config(text=student_name)
    student_class_value.config(text=student_class)
     
    school_name, school_logo = get_school_info()
    if school_name and school_logo:
    school_name_value.config(text=school_name)
     
    subject_info = get_subject_info(student_id, 2024, 1) # Replace with actual year and trimester
    if subject_info:
    subject_tree.delete(*subject_tree.get_children())
    for subject in subject_info:
    subject_tree.insert("", tk.END, values=subject)
     
    average = calculate_grades(subject_info)
    appreciation = generate_appreciation(average)
     
    average_value.config(text=f"{average:.2f}")
    appreciation_value.config(text=appreciation)
     
    def generate_bulletin(subject_info, average, appreciation):
     
    # Retrieve data from labels and entries
    student_name = student_name_value.cget("text")
    student_class = student_class_value.cget("text")
    school_name = school_name_value.cget("text")
    principal_signature = principal_signature_entry.get()
    guardian_signature = guardian_signature_entry.get()
     
    # Generate PDF report using the retrieved data
    generate_bulletin_pdf(
    student_name, student_class, school_name,subject_info, average, appreciation,
    principal_signature, guardian_signature
    )
     
    # Main event loop
    window.mainloop()

  13. #13
    Nouveau Candidat au Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mai 2024
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Enseignement

    Informations forums :
    Inscription : Mai 2024
    Messages : 7
    Points : 0
    Points
    0
    Par défaut
    j m'excurse pour la gene je ne maitrise pas encore assez l'appli. mais j pens ke la mon code est correcte
    un bd "ecole" les tables eleves,ensengnants,notes,annee,trimestre,matiere,classe

  14. #14
    Membre chevronné
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Février 2003
    Messages
    1 582
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Industrie

    Informations forums :
    Inscription : Février 2003
    Messages : 1 582
    Points : 2 030
    Points
    2 030
    Par défaut
    Même si tu as mis ton code entre balises CODE, ce n'est toujours pas bon.

    Regarde ton code publié sur le forum : tu veux qu'on en fasse quoi ? Y a aucune indentation.

Discussions similaires

  1. recuperation de donnees pour generer des bulletins de note
    Par topvision dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 0
    Dernier message: 25/09/2014, 16h08
  2. [MCD] Gestion d'un lycée (sur le bulletin scolaire)
    Par medfatima dans le forum Schéma
    Réponses: 2
    Dernier message: 24/12/2011, 18h33
  3. boost.python : générer les conversions to_python pour des classes abstraites
    Par Blustuff dans le forum Interfaçage autre langage
    Réponses: 2
    Dernier message: 02/08/2011, 11h08
  4. [AC-2010] Besoin coup de mains pour création des tables - Bulletin scolaire
    Par vincmori dans le forum Modélisation
    Réponses: 3
    Dernier message: 28/02/2011, 18h55
  5. Réponses: 1
    Dernier message: 28/01/2011, 11h44

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo