Compare commits

...

19 commits

Author SHA1 Message Date
Elouan GAGEOT 3073f466b4
Merge pull request 'merge-gui' (#4) from merge-gui into main
Reviewed-on: Naomana/Choix_Spe#4
2023-10-16 19:39:17 +00:00
mrraclette 054925ea03 reader into gui 2023-10-16 21:37:36 +02:00
mrraclette de62dfdf44 delete 2023-10-16 20:22:10 +02:00
Elouan GAGEOT 70c7539166
Merge pull request 'GUI' (#3) from GUI into merge-gui
Reviewed-on: Naomana/Choix_Spe#3
2023-10-16 16:40:58 +00:00
Elouan GAGEOT c85bc211f0
Merge pull request 'DataReader' (#2) from DataReader into main
Reviewed-on: Naomana/Choix_Spe#2
2023-10-16 16:37:20 +00:00
Rapahel Lauray 020d433203 rectification erreur fichier 2023-10-16 00:19:51 +02:00
Rapahel Lauray 1ae2c3b1b5 recuperation data et return formation 2023-10-16 00:17:27 +02:00
mrraclette ffc9492577 updates 2023-10-15 14:32:50 +02:00
mrraclette 6f66813396 commit all 2023-10-15 14:20:31 +02:00
mrraclette 8a6fa3e270 Gui fonctionelle 2023-10-15 14:19:49 +02:00
Elouan GAGEOT c3958e4c53
Supprimer GUI/main.py 2023-10-14 22:11:52 +00:00
mrraclette d9137dce04 updates, il faut pouvoir récupérer les données 2023-10-03 03:27:29 +02:00
mrraclette 0aaaab5dea flème de faire un bouton, merci canva 2023-10-03 01:54:31 +02:00
mrraclette b5d201649e Updates 2023-10-03 01:45:19 +02:00
mrraclette e947408949 new icon 2023-10-03 00:54:02 +02:00
mrraclette f51cb4176b delete icon 2023-10-03 00:53:52 +02:00
mrraclette b5e8f8aaf2 import scheme 2023-10-03 00:48:53 +02:00
mrraclette 786f22804e import temp favicon 2023-10-03 00:48:37 +02:00
mrraclette d949c054b0 import py gui 2023-10-03 00:48:10 +02:00
6 changed files with 141 additions and 45 deletions

BIN
assets/Logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
assets/Search_button.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

BIN
assets/bitmap.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

BIN
assets/click_btn1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

141
main.py Normal file
View file

@ -0,0 +1,141 @@
from tkinter import *
from tkinter import ttk
from tkinter import messagebox
import requests, json, jaro, zipfile, os
import tkinter as tk
#Get the name from the web site parcourstup
r = requests.get("https://ressource.parcoursup.fr/data/files.xml")
name = r.content[102:135].decode()
print(f"https://ressource.parcoursup.fr/data/{name}.zip")
# Download the dataset if it doesn't already exist
if not os.path.exists(name):
r = requests.get(f"https://ressource.parcoursup.fr/data/{name}.zip")
with open('data.zip', 'wb') as file:
file.write(r.content)
with zipfile.ZipFile('data.zip', 'r') as zip_ref:
zip_ref.extractall()
# Load database
print("Loading database ...")
with open(name, "r") as file:
database = json.loads(file.read())
def get_formations(prompt: str):
indices = [max([(jaro.jaro_winkler_metric(actual_word, word), index) for word, index in database["lexique"]["index"].items()], key=lambda x: x[0])[1] for actual_word in prompt.split()]
return [f"{formation['nm']} - {list(formation['recS'].keys())[-1]}" for formation in database["formations"].values() if all([str(index) in formation["recW"] for index in indices])]
#creation première fenetre
window = Tk()
def __init__(window):
Tk.__init__(window)
window.create_menu_bar()
#personnalisation fenêtre
window.title("Choix EDS")
window.geometry("1080x720")
window.minsize(480, 360)
window.maxsize(1920, 1080)
window.iconbitmap("assets/bitmap.ico")
window.config()
#Listbox/scrollbar
#création scrollbar
scrollbar = ttk.Scrollbar(window)
listbox = tk.Listbox(window, yscrollcommand=scrollbar.set)
scrollbar.config(command=listbox.yview)
scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
listbox.pack(fill=tk.BOTH, expand=True)
#CREATIONN DES FRAMES
frame = ttk.Frame(listbox)
highframe = ttk.Frame(frame)
bottomframe = ttk.Frame(frame)
#Création menu bar
menubar = Menu(window)
window.config(menu=menubar)
menuabout = Menu(menubar,tearoff=0)
menunon = Menu(menubar,tearoff=0)
def msgabout():
messagebox.showinfo("Choix EDS - En savoir plus ...", "By Raphael et Elouan")
def msgabout1():
messagebox.showinfo("Choix EDS - Code Source", "git : https://git.tipragot.fr/Naomana/Choix_Spe")
def msgabout2():
for i in range (100):
messagebox.showinfo("Choix EDS - Il fallait pas", "Je l'avais, dit, il ne faut pas clicker")
menubar.add_cascade(label="A propos", menu=menuabout)
menubar.add_cascade(label="Non", menu=menunon)
menuabout.add_command(label="Code source", command=msgabout1)
menuabout.add_command(label="En savoir plus...", command=msgabout)
menunon.add_command(label="Ne pas toucher", command=msgabout2)
#AJOUT ET AFFICHAGE DES ELEMENTS
#affichagge image
can = Canvas(highframe, width = 200 , height = 100)
can.pack()
Objet_Image = PhotoImage(file='assets/Logo.png')
Image_Affichee = can.create_image(0,0, image = Objet_Image, anchor='nw')
#ajouter le titre
label_title = ttk.Label(highframe, text="Aide au choix des spécialités", font=("Arial", 31))
#afficher le titre
label_title.pack(side=tk.TOP, pady=8)
#ajouter la description
label_subtitle = ttk.Label(highframe, text="Cette application est une assistance pour le choix des EDS et du parcours post BAC", font=("Arial", 16))
label_subtitle.pack()
#ajouter un champ de texte
int_prompt = ttk.Entry(highframe, font=("Arial", 16))
#afficher le champ de texte
int_prompt.pack(side=LEFT, expand=YES, fill=X, pady=25)
#ajouter un bouton
#définir fonction du bouton
prompt = ""
def getEntry(*_):
prompt = int_prompt.get()
print(get_formations(prompt))
click_btn= PhotoImage(file='assets/Search_button.png')
#Let us create a label for button event
img_label= Label(image=click_btn)
#Let us create a dummy button and pass the image
button= Button(highframe, image=click_btn,command= getEntry,
borderwidth=0)
button.pack(side=RIGHT, pady=30)
#creer bouton
#assingner boutton entrée
window.bind("<Return>", getEntry)
#AFFICHAGE DES FRAMES
#affichage frame haute
highframe.pack(side=TOP)
#affichage frame basse
bottomframe.pack(side=BOTTOM)
#afficher la frame
frame.pack(fill=tk.BOTH)
#TRAITER INFORMATION USER
#Récupérer l'éntrée dans une variable
#affichage dans la boucle main
window.mainloop()

View file

@ -1,45 +0,0 @@
import jaro
import json
# Load database
print("Loading database ...")
with open("data.json", "r") as file:
database = json.loads(file.read())
prompt = input("name > ")
tokens = prompt.split()
# Finding possible words index
possible_words = []
for t in tokens:
found_words = []
for w in database["lexique"]["index"].keys():
if jaro.jaro_winkler_metric(w, t) > 0.93:
index = database["lexique"]["index"][w]
if index not in found_words:
found_words.append(index)
if found_words:
possible_words.append(found_words)
print(possible_words)
# Test every formation
to_test = []
test_passed = []
for f in database["formations"].keys():
checked_count = 0
for ti in database["formations"][f]["recW"].keys():
for found_index in possible_words:
if int(ti) in found_index:
checked_count += 1
break
if checked_count == len(possible_words):
test_passed.append(f)
# Print the result
for f in test_passed:
print(database["formations"][f]["nm"], "at :", list(database["formations"][f]["recS"].keys())[1])