예제 #1
0
def choix_mat(event):
    global idusr, not_nom, not_mat, fen_SupprNote, fr22, fr23
    sn = not_nom.get()
    sup_nom = sn.split(' ')
    list_mat = []

    data_matieres = open('data/data_matieres.txt', 'r')
    dico_matieres = gen.decoup_valtuple(data_matieres)
    data_matieres.close()
    for i in range(0, len(dico_matieres['com'])
                   ):  # Ajout des matières communes dans la liste
        val = dico_matieres['com'][i][0]
        list_mat.append(val)
        data_lv1 = open('data/data_lv1.txt', 'r')
    data_lv1 = open('data/data_lv1.txt', 'r')
    dico_lv1 = gen.decoup_valtuple(data_lv1)
    data_lv1.close()
    for k in dico_lv1:  # Ajout des LV1 dans la liste
        for i in range(0, len(dico_lv1[k])):
            v = dico_lv1[k][i]
            if v == sup_nom:
                key = k + ' LV1'
                list_mat.append(key)
    data_lv2 = open('data/data_lv2.txt', 'r')
    dico_lv2 = gen.decoup_valtuple(data_lv2)
    data_lv2.close()
    for k in dico_lv2:  # Ajout des LV2 dans la liste
        for i in range(0, len(dico_lv2[k])):
            v = dico_lv2[k][i]
            if v == sup_nom:
                key = k + ' LV2'
                list_mat.append(key)
    data_spe = open('data/data_spe.txt', 'r')
    dico_spe = gen.decoup_valtuple(data_spe)
    data_spe.close()
    for k in dico_spe:  # Ajout des Spécialités dans la liste
        for i in range(0, len(dico_spe[k])):
            v = dico_spe[k][i]
            if v == sup_nom:
                key = k + ' SPE'
                list_mat.append(key)
    fr23.pack(fill=X)
    not_not = ttk.Combobox(fr23, values='', state="disabled", width=35)
    not_not.grid(row=0, column=1)
    fr22.pack(fill=X)
    not_mat = ttk.Combobox(fr22, values=list_mat, state="readonly")
    not_mat.grid(row=0, column=1)
    not_mat.bind("<<ComboboxSelected>>", choix_not)
    fen_SupprNote.mainloop()
예제 #2
0
def choix_pers(event):
    global idusr, fen_SupprPers, fr1, fr2, fr21, fr22, usr_nom, usr_profil
    sp = usr_profil.get()
    data_profils = open('data/data_profils.txt', 'r')
    dico_profils = gen.decoup_valtuple(data_profils)
    data_profils.close()

    list_usr = dico_profils[sp]
    list_usr.sort()

    # Affichage combobox utilisateurs
    usr_nom = ttk.Combobox(fr22, values=list_usr, state="readonly")
    usr_nom.grid(row=0, column=1)
예제 #3
0
def choix_mat(event):
    global idusr, fen_SupMat, fr1, fr2, fr21, fr22, mat_type, mat_mat
    sm = mat_type.get()
    if sm == 'Matière Commune':
        nt = 'com'
    elif sm == 'Spécialité':
        nt = 'spe'
    else:
        nt = sm.lower()

    data_matieres = open('data/data_matieres.txt', 'r')
    dico_matieres = gen.decoup_valtuple(data_matieres)
    data_matieres.close()

    list_mat = []
    for i in range(0, len(dico_matieres[nt])):
        list_mat.append(dico_matieres[nt][i][0])
    list_mat.sort()

    # Affichage combobox utilisateurs
    mat_mat = ttk.Combobox(fr22, values=list_mat, state="readonly")
    mat_mat.grid(row=0, column=1)
예제 #4
0
def save_suppers():
    global idusr, fen_SupprPers, usr_nom, usr_profil
    spn = usr_nom.get()
    sup_usr = spn.split(' ')
    sup_profil = usr_profil.get()

    # Suppression de l'utilisateur de la base data_profils
    data_profils = open('data/data_profils.txt', 'r')
    dico_profils = gen.decoup_valtuple(data_profils)
    data_profils.close()
    LU = dico_profils[sup_profil]
    LU.remove(sup_usr)
    del dico_profils[sup_profil]
    dico_profils[sup_profil] = LU
    bdd = 'data/data_profils.txt'
    gen.save_valtuple(bdd, dico_profils)

    # Suppression de l'utilisateur de la base data_pass
    data_pass = open('data/data_pass.txt', 'r')
    dico_pass = gen.decoup_cletuple(data_pass)
    data_pass.close()
    del dico_pass[tuple(sup_usr)]
    bdd = 'data/data_pass.txt'
    gen.save_cletuple(bdd, dico_pass)

    # Suppression des notes de l'utilisateur dans data_notes
    data_notes = open('data/data_notes.txt', 'r')
    dico_notes = gen.decoup_cletvalt(data_notes)
    data_notes.close()
    if tuple(sup_usr) in dico_notes:
        del dico_notes[tuple(sup_usr)]
        bdd = 'data/data_notes.txt'
        gen.save_cletvalt(bdd, dico_notes)

    # Suppression de l'utilisateur de la base data_LV1
    data_lv1 = open('data/data_lv1.txt', 'r')
    dico_lv1 = gen.decoup_valtuple(data_lv1)
    dico_oldlv1 = dico_lv1.copy()
    data_lv1.close()
    for k in dico_oldlv1:
        L1 = dico_lv1[k]
        if sup_usr in L1:
            sup_lv1 = k
            LLV1 = dico_lv1[sup_lv1]
            LLV1.remove(sup_usr)
            del dico_lv1[sup_lv1]
            dico_lv1[sup_lv1] = LLV1
            bdd = 'data/data_lv1.txt'
            gen.save_valtuple(bdd, dico_lv1)

    # Suppression de l'utilisateur de la base data_LV2
    data_lv2 = open('data/data_lv2.txt', 'r')
    dico_lv2 = gen.decoup_valtuple(data_lv2)
    dico_oldlv2 = dico_lv2.copy()
    data_lv2.close()
    for k in dico_oldlv2:
        L2 = dico_lv2[k]
        if sup_usr in L2:
            sup_lv2 = k
            LLV2 = dico_lv2[sup_lv2]
            LLV2.remove(sup_usr)
            del dico_lv2[sup_lv2]
            dico_lv2[sup_lv2] = LLV2
            bdd = 'data/data_lv2.txt'
            gen.save_valtuple(bdd, dico_lv2)

    # Suppression de l'utilisateur de la base data_SPE
    data_spe = open('data/data_spe.txt', 'r')
    dico_spe = gen.decoup_valtuple(data_spe)
    dico_oldspe = dico_spe.copy()
    data_spe.close()
    for k in dico_oldspe:
        LS = dico_spe[k]
        if sup_usr in LS:
            sup_spe = k
            LSPE = dico_spe[sup_spe]
            LSPE.remove(sup_usr)
            del dico_spe[sup_spe]
            dico_spe[sup_spe] = LSPE
            bdd = 'data/data_spe.txt'
            gen.save_valtuple(bdd, dico_spe)

    # Suppression de l'utilisateur (Professeur exclusivement) de la base data_com
    data_com = open('data/data_com.txt', 'r')
    dico_com = gen.decoup_valtuple(data_com)
    dico_oldcom = dico_com.copy()
    data_com.close()
    for k in dico_oldcom:
        LC = dico_com[k]
        if sup_usr in LC:
            sup_com = k
            LCOM = dico_com[sup_com]
            LCOM.remove(sup_usr)
            del dico_com[sup_com]
            dico_com[sup_com] = LCOM
            bdd = 'data/data_com.txt'
            gen.save_valtuple(bdd, dico_com)

    ask = tk.messagebox.askyesno(
        "MERCI",
        "Cet utilisateur a bien été supprimé.\n Souhaitez-vous en supprimer un autre ?",
        parent=fen_SupprPers)
    fen_SupprPers.destroy()
    if ask == True:
        del_perso(idusr)  # retour sur la page d'ajout de personne
    else:
        adm.adm_accueil(idusr)  # retour sur l'accueil d'admin
예제 #5
0
def del_note(nmn):
    global idusr, fen_SupprNote, not_nom, not_mat, not_max, not_coef, not_type, not_not, fr1, fr2, fr21, fr22, fr23, fr3
    idusr = nmn
    ##Saisie nouveau nom
    fen_SupprNote = tk.Tk()
    fen_SupprNote.title("Visual Note")  #titre du logiciel
    fen_SupprNote.geometry("700x720")  #resolution de la fenetre
    fen_SupprNote.iconbitmap(
        "img/vn_logo_2.ico")  #logo en haut a gauche du logiciel
    fen_SupprNote.config(background='white')  #couleur du fond

    #creer les boites
    fr1 = Frame(fen_SupprNote,
                relief=FLAT,
                width=540,
                height=200,
                bd=0,
                bg="white")
    fr1.pack(fill=X)
    fr2 = Frame(fen_SupprNote, relief=FLAT, width=540, height=385, bd=0)
    fr2.pack(fill=X)
    fr21 = Frame(fr2, relief=FLAT, width=540, height=120, bd=0)
    fr21.pack(fill=X)
    fr22 = Frame(fr2, relief=FLAT, width=540, height=120, bd=0)
    fr22.pack(fill=X)
    fr23 = Frame(fr2, relief=FLAT, width=540, height=120, bd=0)
    fr23.pack(fill=X)
    fr3 = Frame(fen_SupprNote,
                relief=FLAT,
                width=540,
                height=100,
                bd=0,
                bg="white")
    fr3.pack(fill=X)

    #creation du logo
    image = PhotoImage(file="img/logo_vn.png").zoom(15).subsample(
        15)  #personalisation de l'image en zoomant
    cnvimg = Canvas(fr1, width=600, height=180, bg="white")
    cnvimg.create_image(330, 85, image=image)
    cnvimg.pack(fill=X)

    #Titre
    label_title = Label(fr1,
                        text="Espace Professeur",
                        font=("Calibri", 40),
                        bg="white",
                        fg="black")
    label_title.pack(expand=YES)

    # message de sous-titre
    label_subtitle = Label(fr1,
                           text="Supression d'une note ",
                           font=("Calibri", 25),
                           bg="white",
                           fg="black")
    label_subtitle.pack(expand=YES)

    # Création de la liste des élèves
    data_profil = open('data/data_profils.txt', 'r')
    dico_profil = gen.decoup_valtuple(data_profil)
    data_profil.close()
    list_noms = []
    list_mat = []
    list_not = []

    for i in range(0, len(dico_profil['Elève'])):
        val = dico_profil['Elève'][i][0] + " " + dico_profil['Elève'][i][1]
        list_noms.append(val)
    list_noms.sort()
    # Choix de l'élève
    txt_nom = tk.Label(fr21,
                       text="Nom de l'élève",
                       font=("Calibri", 16),
                       bg="white",
                       fg="black")
    not_nom = ttk.Combobox(fr21, values=list_noms, state="readonly")
    txt_nom.grid(row=0)
    not_nom.grid(row=0, column=1)
    not_nom.bind("<<ComboboxSelected>>", choix_mat)

    # Choix de la matière
    txt_mat = tk.Label(fr22,
                       text="Matière",
                       font=("Calibri", 16),
                       bg="white",
                       fg="black")
    not_mat = ttk.Combobox(fr22, values=list_mat, state="disabled")
    txt_mat.grid(row=0)
    not_mat.grid(row=0, column=1)

    # Choix de la note à supprimer
    list_not = []
    txt_not = tk.Label(fr23,
                       text="Note à supprimer",
                       font=("Calibri", 16),
                       bg="white",
                       fg="black")
    not_not = ttk.Combobox(fr23, values=list_not, state="disabled", width=35)
    txt_not.grid(row=0)
    not_not.grid(row=0, column=1)

    # Boutons de validation et retour
    bt_valider = tk.Button(fr3,
                           text='Valider',
                           font=("Calibri", 15),
                           bg="white",
                           fg="black",
                           command=save_supnot)
    bt_valider.pack(fill=X)
    bt_retour = tk.Button(fr3,
                          text='Retour',
                          font=("Calibri", 15),
                          bg="white",
                          fg="black",
                          command=retour)
    bt_retour.pack(fill=X)

    fen_SupprNote.mainloop()
예제 #6
0
def addnote (nmn) :
    global idusr, fen_SaisieNote, not_nom, not_mat, not_max, not_coef, not_type, not_not, fr22
    idusr = nmn
    ##Saisie nouveau nom
    fen_SaisieNote = tk.Tk() 
    fen_SaisieNote.title("Visual Note") #titre du logiciel
    fen_SaisieNote.geometry("700x720") #resolution de la fenetre
    fen_SaisieNote.iconbitmap("img/vn_logo_2.ico") #logo en haut a gauche du logiciel
    fen_SaisieNote.config(background='white') #couleur du fond

    # Créer les boites
    fr1=Frame(fen_SaisieNote, relief=FLAT, width=540, height=200, bd=0, bg="white")
    fr1.pack(fill=X)
    fr2 = Frame(fen_SaisieNote, relief=FLAT, width=540, height=385, bd=0)
    fr2.pack(fill=X)
    fr21 = Frame(fr2, relief=FLAT, width=540, height=100, bd=0)
    fr21.pack(fill=X)
    fr22 = Frame(fr2, relief=FLAT, width=540, height=285, bd=0)
    fr22.pack(fill=X)
    fr23 = Frame(fr2, relief=FLAT, width=540, height=285, bd=0)
    fr23.pack(fill=X)
    fr3 = Frame(fen_SaisieNote, relief=FLAT, width=540, height=100, bd=0, bg="white")
    fr3.pack(fill=X)

    #creation du logo
    image = PhotoImage(file="img/logo_vn.png").zoom(15).subsample(15)#personalisation de l'image en zoomant
    cnvimg = Canvas(fr1, width=600 , height = 180 , bg="white")
    cnvimg.create_image(330, 85, image=image)
    cnvimg.pack(fill=X)

    #Titre
    label_title= Label(fr1, text="Espace Professeur", font=("Calibri",40),bg="white",fg="black")
    label_title.pack(expand=YES)

    # message de sous-itre
    label_subtitle= Label(fr1, text="Saisie d'une nouvelle note ", font=("Calibri",25),bg="white",fg="black")
    label_subtitle.pack(expand=YES)


    # Création de la liste des élèves
    data_profil=open('data/data_profils.txt','r')
    dico_profil = gen.decoup_valtuple (data_profil)
    data_profil.close()
    list_noms = []
    for i in range (0, len(dico_profil['Elève'])) :
        val = dico_profil['Elève'][i][0]+" "+dico_profil['Elève'][i][1]
        list_noms.append(val)
    list_noms.sort()

    #Création des listes pour les coefs, note max et type d'examen
    data_bsn=open('data/data_basenotes.txt','r')
    dico_bsn = gen.decoup_valtuple (data_bsn)
    data_bsn.close()
    list_max = []
    list_coef = []
    list_type = []
    for i in range (0, len(dico_bsn['max'])) :     # Ajout des notes max dans la liste
        val = dico_bsn['max'][i][0]
        list_max.append(val)
    for i in range (0, len(dico_bsn['coef'])) :     # Ajout des coefs dans la liste
        val = dico_bsn['coef'][i][0]
        list_coef.append(val)
    for i in range (0, len(dico_bsn['type'])) :     # Ajout des types dans la liste
        val = dico_bsn['type'][i][0]
        list_type.append(val)

    not_nom = tk.StringVar()
    not_mat = tk.StringVar()
    not_max = tk.StringVar()
    not_coef = tk.StringVar()
    not_not = tk.StringVar()

    # Choix de l'élève
    txt_nom = tk.Label(fr21, text="Nom de l'élève", font=("Calibri",16), bg="white", fg="black", width=25)
    not_nom = ttk.Combobox(fr21, values=list_noms, state="readonly")
    txt_nom.grid(row=0)
    not_nom.grid(row=0, column=1)
    not_nom.bind("<<ComboboxSelected>>", chx_mat)

    # Choix de la matière
    txt_mat = tk.Label(fr22, text="Matière", font=("Calibri",16), bg="white", fg="black", width=25)
    not_mat = ttk.Combobox(fr22, values='', state="disabled")
    txt_mat.grid(row=0)
    not_mat.grid(row=0, column=1)

    # Choix de la note max, du coef, du type et de le note attribuée
    txt_max = tk.Label(fr23, text="Note max possible", font=("Calibri",16), bg="white", fg="black", width=25)
    not_max = ttk.Combobox(fr23, values=list_max)
    not_max.current(2)
    txt_max.grid(row=0)
    not_max.grid(row=0, column=1)

    txt_type = tk.Label(fr23, text="Type d'examen", font=("Calibri",16), bg="white", fg="black", width=25)
    not_type = ttk.Combobox(fr23, values=list_type, state="readonly")
    txt_type.grid(row=1)
    not_type.grid(row=1, column=1)

    txt_coef = tk.Label(fr23, text="Coefficient", font=("Calibri",16), bg="white", fg="black", width=25)
    not_coef = ttk.Combobox(fr23, values=list_coef,state="readonly")
    txt_coef.grid(row=2)
    not_coef.grid(row=2, column=1)

    txt_not = tk.Label(fr23, text="Note obtenue", font=("Calibri",16), bg="white", fg="black", width=25)
    not_not = tk.Entry(fr23, textvariable='', width=5)
    txt_not.grid(row=3)
    not_not.grid(row=3, column=1)

    bt_valider = tk.Button(fr3, text='Valider', font = ("Calibri", 15), bg="white", fg="black", command=checknot)
    bt_valider.pack(fill=X)
    bt_retour = tk.Button(fr3, text='Retour', font = ("Calibri", 15), bg="white", fg="black", command=retour)
    bt_retour.pack(fill=X)



    # Afficher la fenêtre
    fen_SaisieNote.mainloop()
예제 #7
0
def notes(nmn):
    global idusr, fen_AffNote, canvas
    # Prérequis : héritage de l'élève concerné
    idusr = nmn
    nom = nmn[0]
    prenom = nmn[1]

    fen_AffNote = Tk()
    fen_AffNote.title("Visual Note")  # Titre du logiciel
    fen_AffNote.geometry("700x720")  # Résolution de la fenetre
    fen_AffNote.iconbitmap(
        "img/vn_logo_2.ico")  # Logo en haut a gauche du logiciel
    fen_AffNote.config(background='white')  # Couleur du fond

    fr1 = Frame(fen_AffNote, relief=FLAT, bd=0, bg="white")
    fr1.pack(fill=X)
    fr2 = Frame(fen_AffNote, relief=FLAT, width=545, height=370, bd=0)
    fr2.pack(fill=X)
    fr2.pack_propagate(0)
    fr3 = Frame(fen_AffNote, relief=FLAT, bd=0, bg="white")
    fr3.pack(fill=X)

    canvas = Canvas(fr2)
    frame = Frame(canvas)
    myscrollbar = Scrollbar(fr2, orient="vertical", command=canvas.yview)
    canvas.configure(yscrollcommand=myscrollbar.set)

    myscrollbar.pack(side="right", fill="y")
    canvas.pack(side="left")
    canvas.create_window((0, 0), window=frame, anchor='nw')
    frame.bind("<Configure>", scrollv)

    # Création du logo
    image = PhotoImage(file="img/logo_vn.png").zoom(15).subsample(
        15)  #personalisation de l'image en zoomant
    cnvimg = Canvas(fr1, width=600, height=180, bg="white")
    cnvimg.create_image(330, 85, image=image)
    cnvimg.pack(fill=X)

    #Titre
    label_title = Label(fr1,
                        text="Espace Elève",
                        font=("Calibri", 40),
                        bg="white",
                        fg="black")
    label_title.pack(expand=YES)

    #message de sous-titre
    label_subtitle = Label(fr1,
                           text='Notes et Moyennes de ' + prenom + ' ' + nom,
                           font=("Calibri", 25),
                           bg="white",
                           fg="black")
    label_subtitle.pack(fill=X)

    #Création de la liste des matières
    data_matieres = open('data/data_matieres.txt', 'r')
    dico_matieres = gen.decoup_valtuple(data_matieres)
    data_matieres.close()
    mat_com = []
    coef_com = []
    for i in range(0, len(dico_matieres['com'])
                   ):  # Ajout des matières communes dans la liste
        val = dico_matieres['com'][i][0]
        cof = dico_matieres['com'][i][1]
        mat_com.append(val)
        coef_com.append(cof)
    ## matières optionnelles de l'élève
    ### LV1
    data_lv1 = open('data/data_lv1.txt', 'r')
    dico_lv1 = gen.decoup_valtuple(data_lv1)
    data_lv1.close()
    for (k) in dico_lv1.keys():  # Ajout de LA matière LV1
        if idusr in dico_lv1[k]:
            mat_lv1 = k
    ### LV2
    data_lv2 = open('data/data_lv2.txt', 'r')
    dico_lv2 = gen.decoup_valtuple(data_lv2)
    data_lv2.close()
    for (k) in dico_lv2.keys():  # Ajout de LA matière LV2
        if idusr in dico_lv2[k]:
            mat_lv2 = k
    ### SPE
    data_spe = open('data/data_spe.txt', 'r')
    dico_spe = gen.decoup_valtuple(data_spe)
    data_spe.close()
    for (k) in dico_spe.keys():  # Ajout de LA matière SPE
        if idusr in dico_spe[k]:
            mat_spe = k

    # Récupération des notes de l'élève
    data_notes = open('data/data_notes.txt', 'r')
    dico_notes = gen.decoup_cletvalt(data_notes)
    data_notes.close()
    if tuple(idusr) in dico_notes:
        list_notes = dico_notes[tuple(idusr)]
    else:
        list_notes = []

    # Affichage tableau des notes
    ## Matières
    ### Matières communes
    m_gen = 0
    c_gen = 0
    for i in range(0, len(mat_com)):
        com = tk.Label(frame, text=mat_com[i], justify='left')
        com.grid(column=0)  # 1ère colonne : intitulés des matières
        mx = 0
        cf = 0
        for t in range(0, len(list_notes)):
            if mat_com[i] == list_notes[t][0]:
                mx = mx + float(list_notes[t][1]) * 20 / int(
                    list_notes[t][2]) * int(list_notes[t][3])
                cf = cf + int(list_notes[t][3])
                note = tk.Label(frame,
                                text=list_notes[t][5] + ' : ' +
                                list_notes[t][1] + '/' + list_notes[t][2] +
                                ' (coef: ' + list_notes[t][3] + ', ' +
                                list_notes[t][4] + ')',
                                justify='left')
                note.grid(column=1)  # 2ème colonne : notes et coefficients...
        if cf == 0:
            c = 0
            m = 0
            moy = 'NA'  # Si aucune note (donc pas de cumul de coefs), afficher NA (Non Applicable)
        else:
            c = int(coef_com[i])
            m = mx / cf  # calcul et affichage de la moyenne pour la matière
            moy = '%2.2f' % m
        moyenne = tk.Label(frame,
                           text='Moyenne : ' + moy + ' /20',
                           justify='left')
        moyenne.grid(column=1)
        m_gen = m_gen + m * c
        c_gen = c_gen + c
    ### LV1
    mx = 0
    cf = 0
    lv1 = tk.Label(frame, text=mat_lv1, justify='left')
    lv1.grid(column=0)  # 1ère colonne : intitulé de la matière concernée
    for t in range(0, len(list_notes)):
        if mat_lv1 == list_notes[t][0]:
            mx = mx + float(list_notes[t][1]) * 20 / int(
                list_notes[t][2]) * int(list_notes[t][3])
            cf = cf + int(list_notes[t][3])
            note = tk.Label(frame,
                            text=list_notes[t][5] + ' : ' + list_notes[t][1] +
                            '/' + list_notes[t][2] + ' (coef: ' +
                            list_notes[t][3] + ', ' + list_notes[t][4] + ')',
                            justify='left')
            note.grid(column=1)  # 2ème colonne : notes et coefficients...
    if cf == 0:
        c = 0
        m = 0
        moy = 'NA'  # Si aucune note (donc pas de cumul de coefs), afficher NA (Non Applicable)
    else:
        c = 3
        m = mx / cf  # calcul et affichage de la moyenne pour la matière
        moy = '%2.2f' % m
    moyenne = tk.Label(frame, text='Moyenne : ' + moy + ' /20', justify='left')
    moyenne.grid(column=1)
    m_gen = m_gen + m * c
    c_gen = c_gen + c
    ### LV2
    mx = 0
    cf = 0
    lv2 = tk.Label(frame, text=mat_lv2, justify='left')
    lv2.grid(column=0)  # 1ère colonne : intitulé de la matière concernée
    for t in range(0, len(list_notes)):
        if mat_lv2 == list_notes[t][0]:
            mx = mx + float(list_notes[t][1]) * 20 / int(
                list_notes[t][2]) * int(list_notes[t][3])
            cf = cf + int(list_notes[t][3])
            note = tk.Label(frame,
                            text=list_notes[t][5] + ' : ' + list_notes[t][1] +
                            '/' + list_notes[t][2] + ' (coef: ' +
                            list_notes[t][3] + ', ' + list_notes[t][4] + ')',
                            justify='left')
            note.grid(column=1)  # 2ème colonne : notes et coefficients...
    if cf == 0:
        c = 0
        m = 0
        moy = 'NA'  # Si aucune note (donc pas de cumul de coefs), afficher NA (Non Applicable)
    else:
        c = 2
        m = mx / cf  # calcul et affichage de la moyenne pour la matière
        moy = '%2.2f' % m
    moyenne = tk.Label(frame, text='Moyenne : ' + moy + ' /20', justify='left')
    moyenne.grid(column=1)
    m_gen = m_gen + m * c
    c_gen = c_gen + c
    ### Spécialités
    mx = 0
    cf = 0
    spe = tk.Label(frame, text=mat_spe, justify='left')
    spe.grid(column=0)  # 1ère colonne : intitulé de la matière concernée
    for t in range(0, len(list_notes)):
        if mat_spe == list_notes[t][0]:
            mx = mx + float(list_notes[t][1]) * 20 / int(
                list_notes[t][2]) * int(list_notes[t][3])
            cf = cf + int(list_notes[t][3])
            note = tk.Label(frame,
                            text=list_notes[t][5] + ' : ' + list_notes[t][1] +
                            '/' + list_notes[t][2] + ' (coef: ' +
                            list_notes[t][3] + ', ' + list_notes[t][4] + ')',
                            justify='left')
            note.grid(column=1)  # 2ème colonne : notes et coefficients...
    if cf == 0:
        c = 0
        m = 0
        moy = 'NA'  # Si aucune note (donc pas de cumul de coefs), afficher NA (Non Applicable)
    else:
        c = 2
        m = mx / cf  # calcul et affichage de la moyenne pour la matière
        moy = '%2.2f' % m
    moyenne = tk.Label(frame, text='Moyenne : ' + moy + ' /20', justify='left')
    moyenne.grid(column=1)
    m_gen = m_gen + m * c
    c_gen = c_gen + c  # Coef 1 par matière --> A modifier à terme pour avoir un coef par matière
    ### Moyenne générale
    if c_gen == 0:
        m_gen = 'NA'  # Si aucune note (donc pas de cumul de coefs), afficher NA (Non Applicable)
    else:
        m = m_gen / c_gen  # calcul et affichage de la moyenne générale
        moy = '%2.2f' % m
    txt_moy = tk.Label(frame, text='Moyenne Générale : ', justify='left')
    txt_moy.grid(column=0)
    not_moy = tk.Label(frame, text=moy + ' /20', justify='left')
    not_moy.grid(column=1)

    bt_retour = tk.Button(fr3,
                          text='Retour',
                          font=("Calibri", 15),
                          bg="white",
                          fg="black",
                          command=retour)
    bt_retour.pack(fill=X)

    fen_AffNote.mainloop()
예제 #8
0
def checkmat():
    global idusr, fen_SaisieMat, mat_coef, mat_nom, mat_prf
    chm_nom = mat_nom.get()
    chm_prf = mat_prf.get()
    chm_coef = mat_coef.get()

    ## Découpage des entrées de la BDD (mots de passe) clé / data (élève / notes et arguments)
    data_matieres = open('data/data_matieres.txt', 'r')
    dico_matieres = gen.decoup_valtuple(data_matieres)
    data_matieres.close()

    LM = []
    for k in dico_matieres:
        for i in range(0, len(dico_matieres[k])):
            LM.append(dico_matieres[k][i][0])

    if chm_nom == '' or chm_prf == '' or chm_coef == '':
        tk.messagebox.showwarning(
            'ATTENTION',
            'Tous les champs doivent être remplis !\nMerci de corriger.',
            parent=fen_SaisieMat)
    else:
        ret = check_num(chm_coef)
        res = check_alpha(chm_nom)
        if ret != 'ok':
            tk.messagebox.showwarning('ATTENTION', ret, parent=fen_SaisieMat)
        elif int(chm_coef) < 1 or int(chm_coef) > 20:
            tk.messagebox.showwarning(
                'ATTENTION',
                'Merci de saisir un coeffficient valide (compris entre 1 et 20).',
                parent=fen_SaisieMat)
        elif res != 'ok':
            tk.messagebox.showwarning('ATTENTION', res, parent=fen_SaisieMat)
        elif chm_nom in LM:
            tk.messagebox.showwarning(
                'ATTENTION',
                'Cette matière existe déjà.\nMerci de corriger.',
                parent=fen_SaisieMat)
        else:
            if chm_prf == 'Matière Commune':
                key = 'com'
            elif chm_prf == 'LV1':
                key = 'lv1'
            elif chm_prf == 'LV2':
                key = 'lv2'
            else:
                key = 'spe'

            val = [chm_nom, chm_coef]

            # Ajout des nouvelles entrées au dictionnaire Matières
            gen.ajout_dico(dico_matieres, val, key)
            # Sauvegarde des dictionnaires dans le fichier texte
            bdd = 'data/data_matieres.txt'
            gen.save_valtuple(bdd, dico_matieres)
            ask = tk.messagebox.askyesno(
                "MERCI",
                "Cette matière a bien été ajoutée.\nSouhaitez-vous en ajouter une autre ?",
                parent=fen_SaisieMat)
            fen_SaisieMat.destroy()
            if ask == True:
                addmat(idusr)  # retour sur la page d'ajout de personne
            else:
                adm.adm_accueil(idusr)  # retour sur l'accueil d'admin
예제 #9
0
def check_supMat():
    global idusr, fen_SupMat, mat_type, mat_mat
    sup_mat = mat_mat.get()
    nt = mat_type.get()

    if sup_mat == '' or nt == '':
        ask = tk.messagebox.showwarning(
            "ATTENTION",
            "Tous les champs doivent être remplis.\nMerci de corriger.",
            parent=fen_SupMat)
    else:
        data_not = open('data/data_notes.txt', 'r')
        dico_not = gen.decoup_valtuple(data_not)
        data_not.close()
        xy = 'ok'
        for k in dico_not:
            for i in range(0, len(dico_not[k])):
                if dico_not[k][i][0] == sup_mat:
                    xy = 'ko'
        if xy != 'ko':
            ask = tk.messagebox.askyesno(
                "ATTENTION",
                "Cette opération va supprimer la matière dans TOUTES les bases de données.\nÊtes-vous sûr(e) de vouloir continuer ?",
                parent=fen_SupMat)
            if ask == True:
                # Suppression de l'utilisateur de la base data_com, data_lv1, data_lv2, data_spe
                if nt == 'Matière Commune':
                    sup_type = 'com'
                elif nt == 'Spécialité':
                    sup_type = 'spe'
                else:
                    sup_type = nt.lower()

                tp = 'data/data_' + sup_type + '.txt'
                data_typ = open(tp, 'r')
                dico_typ = gen.decoup_valtuple(data_typ)
                data_typ.close()

                if sup_mat in dico_typ.keys():
                    del dico_typ[sup_mat]
                    bdd = 'data/data_' + sup_type + '.txt'
                    gen.save_valtuple(bdd, dico_typ)

                # Suppression de l'utilisateur de la base data_matieres
                data_matieres = open('data/data_matieres.txt', 'r')
                dico_matieres = gen.decoup_valtuple(data_matieres)
                data_matieres.close()
                LM = dico_matieres[sup_type].copy()
                for i in range(0, len(dico_matieres[sup_type])):
                    if dico_matieres[sup_type][i][0] == sup_mat:
                        LM.remove(dico_matieres[sup_type][i])
                del dico_matieres[sup_type]
                dico_matieres[sup_type] = LM
                bdd = 'data/data_matieres.txt'
                gen.save_valtuple(bdd, dico_matieres)
                ask = tk.messagebox.askyesno(
                    "MERCI",
                    "Cette matière a bien été supprimée.\n Souhaitez-vous en supprimer une autre ?",
                    parent=fen_SupMat)
                fen_SupMat.destroy()
                if ask == True:
                    del_mat(idusr)  # retour sur la page d'ajout de personne
                else:
                    adm.adm_accueil(idusr)  # retour sur l'accueil d'admin
        else:
            tk.messagebox.showerror(
                "ERREUR",
                "Des élèves ont des notes dans cette matière.\nVous devez retirer les notes AVANT de supprimer une matière.",
                parent=fen_SupMat)
예제 #10
0
def chg_pass(n):
    global idusr, fen_ChgPass, ch_mdpold, ch_mdpn1, ch_mdpn2, pfs

    idusr = n

    # Détermination du profil de l'utilisateur
    data_profils = open('data/data_profils.txt', 'r')
    dico_profils = gen.decoup_valtuple(data_profils)
    data_profils.close()
    data_pass = open('data/data_pass.txt', 'r')
    dico_pass = gen.decoup_cletuple(data_pass)
    data_pass.close()
    L1 = []
    L2 = []
    for key in dico_pass.keys():
        L1 = [key[0], key[1], dico_pass[key]]
        L2.append(L1)
    pfs = gen.find_key(idusr, dico_profils)

    # Affichage de la fenêtre
    fen_ChgPass = tk.Tk()

    fen_ChgPass.title("Visual Note")  #titre du logiciel
    fen_ChgPass.geometry("700x720")  #resolution de la fenetre
    fen_ChgPass.iconbitmap(
        "img/vn_logo_2.ico")  #logo en haut a gauche du logiciel
    fen_ChgPass.config(background='white')  #couleur du fond

    ## creer les boites
    fr1 = Frame(fen_ChgPass,
                relief=FLAT,
                width=540,
                height=200,
                bd=0,
                bg="white")
    fr1.pack(fill=X)
    fr2 = Frame(fen_ChgPass, relief=FLAT, width=540, height=385, bd=0)
    fr2.pack(fill=X)
    fr3 = Frame(fen_ChgPass,
                relief=FLAT,
                width=540,
                height=100,
                bd=0,
                bg="white")
    fr3.pack(fill=X)

    ## création du logo
    image = PhotoImage(file="img/logo_vn.png").zoom(15).subsample(
        15)  #personalisation de l'image en zoomant
    cnvimg = Canvas(fr1, width=600, height=180, bg="white")
    cnvimg.create_image(330, 85, image=image)
    cnvimg.pack(fill=X)

    ## Titre
    label_title = Label(fr1,
                        text="Espace " + pfs,
                        font=("Calibri", 40),
                        bg="white",
                        fg="black")
    label_title.pack(expand=YES)

    ## message de sous-titre
    label_subtitle = Label(fr1,
                           text="Modification du mot de passe",
                           font=("Calibri", 25),
                           bg="white",
                           fg="black")
    label_subtitle.pack(expand=YES)

    ## Mot de passe actuel
    txt_mdpold = tk.Label(fr2,
                          text="Mot de passe actuel",
                          font=("Calibri", 25),
                          bg="white",
                          fg="black")
    ch_mdpold = tk.Entry(fr2, show='*', textvariable='', width=45)
    txt_mdpold.grid(row=0, column=0)
    ch_mdpold.grid(row=0, column=1)
    txt_mdpold = tk.Label(fr2, text="", bg="white",
                          fg="black")  # ligne vide (saut de ligne)
    txt_mdpold.grid(row=1)

    ## Nouveau mot de passe
    txt_mdpn1 = tk.Label(fr2,
                         text="Nouveau mot de passe",
                         font=("Calibri", 25),
                         bg="white",
                         fg="black")
    ch_mdpn1 = tk.Entry(fr2, show='*', textvariable='', width=45)
    txt_mdpn1.grid(row=2, column=0)
    ch_mdpn1.grid(row=2, column=1)
    txt_mdpn2 = tk.Label(fr2,
                         text="Saisissez-le à nouveau",
                         font=("Calibri", 25),
                         bg="white",
                         fg="black")
    ch_mdpn2 = tk.Entry(fr2, show='*', textvariable='', width=45)
    txt_mdpn2.grid(row=3, column=0)
    ch_mdpn2.grid(row=3, column=1)

    # Boutons de validation et sortie
    bt_valid = tk.Button(fr3,
                         text='Valider',
                         font=("Calibri", 15),
                         bg="white",
                         fg="black",
                         command=checkpass)
    bt_valid.pack(fill=X)
    bt_retour = tk.Button(fr3,
                          text='Retour',
                          font=("Calibri", 15),
                          bg="white",
                          fg="black",
                          command=retour)
    bt_retour.pack(fill=X)

    fen_ChgPass.mainloop()