From 768f7feb7793b8ae7509602af27227a3f3b45a25 Mon Sep 17 00:00:00 2001 From: "barraux.a" Date: Mon, 9 May 2022 09:56:03 +0200 Subject: [PATCH 1/4] hj,n --- main.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..df880a0 --- /dev/null +++ b/main.py @@ -0,0 +1,30 @@ +from kivy.app import App +from kivy.graphics import Ellipse, Line +from kivy.uix.boxlayout import BoxLayout +from kivy.uix.textinput import TextInput + +class CustomLayout(BoxLayout): + + def __init__(self, **kwargs): + super(CustomLayout, self).__init__(**kwargs) + with self.canvas.after: + pass + self.textinput = TextInput(text='Hello world', multiline=False) + self.add_widget(self.textinput) + self.textinput.bind(on_text_validate=self.on_enter) + + def on_enter(self,instance, value): + print('User pressed enter in', instance) + + + + +class MainApp(App): + + def build(self): + root = CustomLayout() + return root + +if __name__ == '__main__': + MainApp().run() + From 711830cce92d339c85ba7efd60c602a16b6784d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?CLOCHARD=20L=C3=A9andre?= Date: Thu, 12 May 2022 09:13:29 +0200 Subject: [PATCH 2/4] =?UTF-8?q?Transf=C3=A9rer=20les=20fichiers=20vers=20'?= =?UTF-8?q?'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fichier lecture --- lecture_csv.py | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/lecture_csv.py b/lecture_csv.py index 867caf2..cf52f1a 100644 --- a/lecture_csv.py +++ b/lecture_csv.py @@ -1,10 +1,21 @@ -import csv - -def lecture(fichier_csv): - "renvoie un tabeau" - with open(fichier_csv, newline='') as csvfile: - spamreader = csv.reader(csvfile, delimiter=' ', quotechar='|') - for row in spamreader: - print(', '.join(row)) - -lecture("jeuTests.csv") \ No newline at end of file +def lecture(name): + """lit le fichier csv dont le nom est passé en paramètre, en renvoie trois tableau contenant + respectivement la longueur et la largeur des pétales, et l'espèce de l'iris.""" + lst_date = [] + lst_pic = [] + lst_temp_moy = [] + lst_temp_ref = [] + with open(name) as fic: + fic.readline() + for ligne in fic: + date, pic, temp_moy, temp_ref = ligne.split(';') + lst_date.append(date) + lst_pic.append(float(pic)) + lst_temp_moy.append(float(temp_moy)) + lst_temp_ref.append(float(temp_ref)) + + + return lst_date, lst_pic, lst_temp_moy, lst_temp_ref + +print(lecture("jeuTests.csv")) + \ No newline at end of file From f87d2108bd743ed1efe6104c4e5d75150750df1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?CLOCHARD=20L=C3=A9andre?= Date: Thu, 12 May 2022 09:43:47 +0200 Subject: [PATCH 3/4] =?UTF-8?q?Transf=C3=A9rer=20les=20fichiers=20vers=20'?= =?UTF-8?q?'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit creation fonction numero jour --- lecture_csv.py | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/lecture_csv.py b/lecture_csv.py index cf52f1a..dd1bf85 100644 --- a/lecture_csv.py +++ b/lecture_csv.py @@ -1,21 +1,26 @@ +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 + def lecture(name): """lit le fichier csv dont le nom est passé en paramètre, en renvoie trois tableau contenant respectivement la longueur et la largeur des pétales, et l'espèce de l'iris.""" - lst_date = [] - lst_pic = [] - lst_temp_moy = [] - lst_temp_ref = [] + lst_return = [] with open(name) as fic: fic.readline() for ligne in fic: date, pic, temp_moy, temp_ref = ligne.split(';') - lst_date.append(date) - lst_pic.append(float(pic)) - lst_temp_moy.append(float(temp_moy)) - lst_temp_ref.append(float(temp_ref)) - - - return lst_date, lst_pic, lst_temp_moy, lst_temp_ref + tuple_date = (numeroJour(date) ,float(temp_moy), float(temp_ref)) + lst_return.append([float(pic), tuple_date]) + + return lst_return print(lecture("jeuTests.csv")) - \ No newline at end of file + + + + \ No newline at end of file From 6a0386135055d67fe11db772aa8f6c1d38beec9c Mon Sep 17 00:00:00 2001 From: "barraux.a" Date: Sun, 15 May 2022 16:16:49 +0200 Subject: [PATCH 4/4] Interface graphique --- lecture_csv.py | 9 ++++-- main.py | 76 +++++++++++++++++++++++++++++++++----------------- 2 files changed, 57 insertions(+), 28 deletions(-) diff --git a/lecture_csv.py b/lecture_csv.py index dd1bf85..4b9ed43 100644 --- a/lecture_csv.py +++ b/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 diff --git a/main.py b/main.py index df880a0..dfb6c61 100644 --- a/main.py +++ b/main.py @@ -1,30 +1,56 @@ -from kivy.app import App -from kivy.graphics import Ellipse, Line -from kivy.uix.boxlayout import BoxLayout -from kivy.uix.textinput import TextInput +import tkinter as tk +from tkinter import messagebox +import lecture_csv -class CustomLayout(BoxLayout): - - def __init__(self, **kwargs): - super(CustomLayout, self).__init__(**kwargs) - with self.canvas.after: - pass - self.textinput = TextInput(text='Hello world', multiline=False) - self.add_widget(self.textinput) - self.textinput.bind(on_text_validate=self.on_enter) - - def on_enter(self,instance, value): - print('User pressed enter in', instance) +class Main_frame(tk.Frame): + """Créer la Frame principal""" + def __init__(self, root): + super().__init__(root) + self._build() + self.pack() - - -class MainApp(App): - - def build(self): - root = CustomLayout() - return root + 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__': - MainApp().run() - + app = tk.Tk() + Main_frame(app) + app.mainloop() \ No newline at end of file