merge-gui #4
|
@ -1,25 +0,0 @@
|
||||||
import requests, json, jaro, zipfile, os
|
|
||||||
|
|
||||||
#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])]
|
|
||||||
|
|
||||||
print(get_formations(input("Votre projet > ")))
|
|
76
main.py
76
main.py
|
@ -1,9 +1,34 @@
|
||||||
from tkinter import *
|
from tkinter import *
|
||||||
from tkinter import ttk
|
from tkinter import ttk
|
||||||
from tkinter import messagebox
|
from tkinter import messagebox
|
||||||
|
import requests, json, jaro, zipfile, os
|
||||||
|
|
||||||
import tkinter as tk
|
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
|
#creation première fenetre
|
||||||
window = Tk()
|
window = Tk()
|
||||||
def __init__(window):
|
def __init__(window):
|
||||||
|
@ -14,16 +39,9 @@ window.title("Choix EDS")
|
||||||
window.geometry("1080x720")
|
window.geometry("1080x720")
|
||||||
window.minsize(480, 360)
|
window.minsize(480, 360)
|
||||||
window.maxsize(1920, 1080)
|
window.maxsize(1920, 1080)
|
||||||
window.iconbitmap("GUI/bitmap.ico")
|
window.iconbitmap("assets/bitmap.ico")
|
||||||
window.config()
|
window.config()
|
||||||
|
|
||||||
Thm = "#aaaaaa"
|
|
||||||
def makeSomething1():
|
|
||||||
Thm = "#aaaaaa"
|
|
||||||
print(Thm)
|
|
||||||
def makeSomething2():
|
|
||||||
Thm = "#35363a"
|
|
||||||
print(Thm)
|
|
||||||
#Listbox/scrollbar
|
#Listbox/scrollbar
|
||||||
#création scrollbar
|
#création scrollbar
|
||||||
scrollbar = ttk.Scrollbar(window)
|
scrollbar = ttk.Scrollbar(window)
|
||||||
|
@ -32,24 +50,14 @@ scrollbar.config(command=listbox.yview)
|
||||||
|
|
||||||
scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
|
scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
|
||||||
listbox.pack(fill=tk.BOTH, expand=True)
|
listbox.pack(fill=tk.BOTH, expand=True)
|
||||||
|
|
||||||
#CREATIONN DES FRAMES
|
#CREATIONN DES FRAMES
|
||||||
#création d'une frame principale
|
|
||||||
frame = ttk.Frame(listbox)
|
frame = ttk.Frame(listbox)
|
||||||
|
|
||||||
#création d'une frame haute
|
|
||||||
highframe = ttk.Frame(frame)
|
highframe = ttk.Frame(frame)
|
||||||
|
|
||||||
#création d'une frame basse
|
|
||||||
bottomframe = ttk.Frame(frame)
|
bottomframe = ttk.Frame(frame)
|
||||||
|
|
||||||
#création d'une frame gauche
|
|
||||||
leftframe = ttk.Frame(bottomframe)
|
|
||||||
|
|
||||||
#création d'une frame droite
|
|
||||||
rightframe = ttk.Frame(bottomframe)
|
|
||||||
|
|
||||||
#Création menu bar
|
#Création menu bar
|
||||||
|
|
||||||
menubar = Menu(window)
|
menubar = Menu(window)
|
||||||
window.config(menu=menubar)
|
window.config(menu=menubar)
|
||||||
menuabout = Menu(menubar,tearoff=0)
|
menuabout = Menu(menubar,tearoff=0)
|
||||||
|
@ -68,15 +76,12 @@ menuabout.add_command(label="En savoir plus...", command=msgabout)
|
||||||
menunon.add_command(label="Ne pas toucher", command=msgabout2)
|
menunon.add_command(label="Ne pas toucher", command=msgabout2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#AJOUT ET AFFICHAGE DES ELEMENTS
|
#AJOUT ET AFFICHAGE DES ELEMENTS
|
||||||
#affichagge image
|
#affichagge image
|
||||||
can = Canvas(highframe, width = 200 , height = 100)
|
can = Canvas(highframe, width = 200 , height = 100)
|
||||||
|
|
||||||
can.pack()
|
can.pack()
|
||||||
Objet_Image = PhotoImage(file='GUI/Logo.png')
|
Objet_Image = PhotoImage(file='assets/Logo.png')
|
||||||
Image_Affichee = can.create_image(0,0, image = Objet_Image, anchor='nw')
|
Image_Affichee = can.create_image(0,0, image = Objet_Image, anchor='nw')
|
||||||
#ajouter le titre
|
#ajouter le titre
|
||||||
label_title = ttk.Label(highframe, text="Aide au choix des spécialités", font=("Arial", 31))
|
label_title = ttk.Label(highframe, text="Aide au choix des spécialités", font=("Arial", 31))
|
||||||
|
@ -85,39 +90,36 @@ label_title.pack(side=tk.TOP, pady=8)
|
||||||
|
|
||||||
#ajouter la description
|
#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 = ttk.Label(highframe, text="Cette application est une assistance pour le choix des EDS et du parcours post BAC", font=("Arial", 16))
|
||||||
#afficher la description
|
|
||||||
label_subtitle.pack()
|
label_subtitle.pack()
|
||||||
|
|
||||||
#ajouter un champ de texte
|
#ajouter un champ de texte
|
||||||
int_prompt = ttk.Entry(leftframe, font=("Arial", 16))
|
int_prompt = ttk.Entry(highframe, font=("Arial", 16))
|
||||||
#afficher le champ de texte
|
#afficher le champ de texte
|
||||||
int_prompt.pack(expand=YES, fill=X, pady=25)
|
int_prompt.pack(side=LEFT, expand=YES, fill=X, pady=25)
|
||||||
|
|
||||||
#ajouter un bouton
|
#ajouter un bouton
|
||||||
#définir fonction du bouton
|
#définir fonction du bouton
|
||||||
|
|
||||||
|
prompt = ""
|
||||||
|
|
||||||
def getEntry(*_):
|
def getEntry(*_):
|
||||||
prompt = int_prompt.get()
|
prompt = int_prompt.get()
|
||||||
print(prompt)
|
print(get_formations(prompt))
|
||||||
|
|
||||||
click_btn= PhotoImage(file='GUI/Search_button.png')
|
click_btn= PhotoImage(file='assets/Search_button.png')
|
||||||
#Let us create a label for button event
|
#Let us create a label for button event
|
||||||
img_label= Label(image=click_btn)
|
img_label= Label(image=click_btn)
|
||||||
|
|
||||||
#Let us create a dummy button and pass the image
|
#Let us create a dummy button and pass the image
|
||||||
button= Button(rightframe, image=click_btn,command= getEntry,
|
button= Button(highframe, image=click_btn,command= getEntry,
|
||||||
borderwidth=0)
|
borderwidth=0)
|
||||||
button.pack(pady=30)
|
button.pack(side=RIGHT, pady=30)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#creer bouton
|
#creer bouton
|
||||||
|
|
||||||
#assingner boutton entrée
|
#assingner boutton entrée
|
||||||
window.bind("<Return>", getEntry)
|
window.bind("<Return>", getEntry)
|
||||||
|
|
||||||
|
|
||||||
#AFFICHAGE DES FRAMES
|
#AFFICHAGE DES FRAMES
|
||||||
#affichage frame haute
|
#affichage frame haute
|
||||||
highframe.pack(side=TOP)
|
highframe.pack(side=TOP)
|
||||||
|
@ -125,11 +127,6 @@ highframe.pack(side=TOP)
|
||||||
#affichage frame basse
|
#affichage frame basse
|
||||||
bottomframe.pack(side=BOTTOM)
|
bottomframe.pack(side=BOTTOM)
|
||||||
|
|
||||||
#affichage frame droite
|
|
||||||
rightframe.pack(side=RIGHT, padx=10)
|
|
||||||
|
|
||||||
#affichage frame gauche
|
|
||||||
leftframe.pack(side=LEFT, padx=10)
|
|
||||||
|
|
||||||
#afficher la frame
|
#afficher la frame
|
||||||
frame.pack(fill=tk.BOTH)
|
frame.pack(fill=tk.BOTH)
|
||||||
|
@ -139,5 +136,6 @@ frame.pack(fill=tk.BOTH)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#affichage dans la boucle main
|
#affichage dans la boucle main
|
||||||
window.mainloop()
|
window.mainloop()
|
Loading…
Reference in a new issue