|
|
|
import tkinter as tk
|
|
|
|
from test import lancerTest
|
|
|
|
from tkinter import ttk
|
|
|
|
from selection import DateSelection, TemperatureSelection, VoisinSelection
|
|
|
|
|
|
|
|
class Interface(tk.Frame):
|
|
|
|
def __init__(self, master):
|
|
|
|
"""initialisation de l'interface"""
|
|
|
|
|
|
|
|
self.master = master
|
|
|
|
tk.Frame.__init__(self, master)
|
|
|
|
|
|
|
|
self.create_menu_bar()
|
|
|
|
|
|
|
|
self.tabs = ttk.Notebook(self.master)
|
|
|
|
self.create_tabs()
|
|
|
|
|
|
|
|
|
|
|
|
def create_menu_bar(self):
|
|
|
|
"""crée la barre de menu"""
|
|
|
|
|
|
|
|
menu_bar = tk.Menu(self)
|
|
|
|
|
|
|
|
menu_file = tk.Menu(menu_bar, tearoff=0)
|
|
|
|
menu_file.add_command(label="Quitter", command=self.master.destroy)
|
|
|
|
menu_bar.add_cascade(label="Fichier", menu=menu_file)
|
|
|
|
|
|
|
|
self.master['menu']=menu_bar
|
|
|
|
|
|
|
|
def create_tabs(self):
|
|
|
|
"""crée les onglets et les widgets à l'intérieur"""
|
|
|
|
|
|
|
|
tabAccueil = tk.Frame(self.tabs)
|
|
|
|
tabTest = tk.Frame(self.tabs)
|
|
|
|
tabRes = tk.Frame(self.tabs)
|
|
|
|
self.tabs.add(tabAccueil, text="Accueil")
|
|
|
|
self.tabs.add(tabTest, text="Données")
|
|
|
|
self.tabs.add(tabRes, text="Résultats")
|
|
|
|
self.tabs.pack(expand=1, fill='both')
|
|
|
|
#accueil
|
|
|
|
tk.Label(tabAccueil, text="Vizion", font=("Magneto", 70)).pack()
|
|
|
|
tk.Label(tabAccueil, text="Aɴᴀʟʏsᴇs - Pʀᴇᴅɪᴄᴛɪᴏɴs", font=("arial", 10)).pack()
|
|
|
|
|
|
|
|
tk.Button(tabAccueil, text='Commencer un nouveau test', padx=10, pady=10, command=lambda :self.tabs.select(tabTest)).pack(pady=50)
|
|
|
|
#test
|
|
|
|
self.nb_voisins_proches = VoisinSelection(tabTest)
|
|
|
|
|
|
|
|
param = tk.LabelFrame(tabTest, text="Paramètres", padx=20, pady=20)
|
|
|
|
param.pack()
|
|
|
|
|
|
|
|
self.choix_date = DateSelection(param)
|
|
|
|
self.choix_temp_moy = TemperatureSelection(param, "Température moyenne")
|
|
|
|
self.choix_temp_ref = TemperatureSelection(param, "Température de référence")
|
|
|
|
self.EuclidOrManhattan = tk.IntVar()
|
|
|
|
tk.Radiobutton(tabTest, text="Distance euclidienne", variable=self.EuclidOrManhattan, value=1).pack()
|
|
|
|
tk.Radiobutton(tabTest, text="Distance de manhattan", variable=self.EuclidOrManhattan, value=0).pack()
|
|
|
|
|
|
|
|
|
|
|
|
btn_entrer = tk.Button(tabTest, text='Tester', command=lambda : self.affResTest(tabRes))
|
|
|
|
btn_entrer.pack()
|
|
|
|
#res
|
|
|
|
tk.Label(tabRes, text="Résultat", font=(42)).pack()
|
|
|
|
self.affichage_resultats = tk.Label(tabRes, text="", font=("Courier", 15))
|
|
|
|
self.affichage_resultats.pack()
|
|
|
|
|
|
|
|
def affResTest(self, tab):
|
|
|
|
"""affiche le résultat du test dans le label
|
|
|
|
self.affichage_resultats dans l'onglet TabRes"""
|
|
|
|
|
|
|
|
k = self.nb_voisins_proches.get()
|
|
|
|
date_choisie = self.choix_date.get()
|
|
|
|
temperature_moyenne = self.choix_temp_moy.get()
|
|
|
|
temperature_ref = self.choix_temp_ref.get()
|
|
|
|
isEuclideanDistance = self.EuclidOrManhattan.get()
|
|
|
|
|
|
|
|
res = str(lancerTest(k, (date_choisie, temperature_moyenne, temperature_ref), isEuclideanDistance))
|
|
|
|
self.affichage_resultats['text'] = "La consommation électrique \nprévue est de " + res + " MW."
|
|
|
|
self.tabs.select(tab)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
root = tk.Tk()
|
|
|
|
root.title("Vizion")
|
|
|
|
root.geometry("380x500")
|
|
|
|
app = Interface(root)
|
|
|
|
app.mainloop()
|