Browse Source

normalement rien a changé

master
leandre.clochard 2 years ago
parent
commit
c1416be3a7
  1. 14
      lecture_csv.py
  2. 56
      main.py

14
lecture_csv.py

@ -2,9 +2,12 @@ import datetime
def numeroJour(date):
"""renvoie un entier correspondant au numéro du jour correspondant (entre 1 et 365)"""
day = datetime.datetime.strptime(date, "%Y-%m-%d")
num_day = day.strftime('%j')
return num_day
try:
day = datetime.datetime.strptime(date, "%Y-%m-%d")
num_day = day.strftime('%j')
return int(num_day)
except(ValueError):
return None
def lecture(name):
"""lit le fichier csv dont le nom est passé en paramètre, en renvoie trois tableau contenant
@ -18,9 +21,4 @@ def lecture(name):
lst_return.append([float(pic), tuple_date])
return lst_return
print(lecture("jeuTests.csv"))

56
main.py

@ -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…
Cancel
Save