leandre.clochard
3 years ago
2 changed files with 62 additions and 8 deletions
@ -0,0 +1,56 @@ |
|||
import tkinter as tk |
|||
from tkinter import messagebox |
|||
import lecture_csv |
|||
|
|||
class Main_frame(tk.Frame): |
|||
"""Créer la Frame principal""" |
|||
def __init__(self, root): |
|||
super().__init__(root) |
|||
self._build() |
|||
self.pack() |
|||
|
|||
|
|||
def _build(self): |
|||
text_voisin = tk.Label(self, text='Entrez le nombre de voisins: ') |
|||
text_voisin.grid(column=2, row=0) |
|||
self.nombre_de_voisin = tk.Entry(self, width=20, textvariable=tk.IntVar()) |
|||
self.nombre_de_voisin.grid(column=3, row=0) |
|||
|
|||
text_date = tk.Label(self, text='Entrez la date : ') |
|||
self.date = tk.Entry(self, width=20, textvariable=tk.StringVar()) |
|||
text_date.grid(column=0, row=1) |
|||
self.date.grid(column=1, row=1) |
|||
|
|||
text_temp_moy = tk.Label(self, text='Entrez la température moyenne : ') |
|||
self.temp_moy = tk.Entry(self, width=20, textvariable=tk.DoubleVar()) |
|||
text_temp_moy.grid(column=2, row=1) |
|||
self.temp_moy.grid(column=3, row=1) |
|||
|
|||
text_temp_ref = tk.Label(self, text='Entrez la température de référence : ') |
|||
self.temp_ref = tk.Entry(self, width=20, textvariable=tk.DoubleVar()) |
|||
text_temp_ref.grid(column=4, row=1) |
|||
self.temp_ref.grid(column=5, row=1) |
|||
|
|||
validate_button = tk.Button(self, text='Lancer la recherche', command=self.validate) |
|||
validate_button.grid(column=3, columnspan=2, row=2) |
|||
|
|||
def validate(self): |
|||
value = [self.nombre_de_voisin.get(), self.date.get(), self.temp_moy.get(), self.temp_ref.get()] |
|||
|
|||
try: |
|||
value[0] = int(value[0]) |
|||
value[2] = float(value[2]) |
|||
value[3] = float(value[3]) |
|||
except(ValueError): |
|||
messagebox.showerror('Erreur', 'Veuillez saisir des valeurs correctes !') |
|||
|
|||
if value[0] != 0 and lecture_csv.numeroJour(value[1]) != None: |
|||
value[1] = lecture_csv(value[1]) |
|||
print(value[1]) |
|||
else: |
|||
messagebox.showerror('Erreur', 'Date ou nombre de voisin nuls') |
|||
|
|||
if __name__ == '__main__': |
|||
app = tk.Tk() |
|||
Main_frame(app) |
|||
app.mainloop() |
Loading…
Reference in new issue