From 5de018c45610f97babf8a13b0c02eb0fe321c027 Mon Sep 17 00:00:00 2001 From: Nawel HEBRI <nawel.hebri@edu.univ-paris13.fr> Date: Sat, 28 Dec 2024 23:44:59 +0100 Subject: [PATCH 01/21] Ajout de requete methode 2 --- requete.py | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 requete.py diff --git a/requete.py b/requete.py new file mode 100644 index 0000000..24252cc --- /dev/null +++ b/requete.py @@ -0,0 +1,118 @@ +def request(): + request1 = "SELECT distinct name FROM ethnic WHERE " + request2 = "SELECT distinct name FROM general WHERE " + + tab = [] + + test = 0 + + if _name != None: + tab += "name" + if _ingr != None: + tab += "ingredients": + if _diet != None: + tab += "diet" + if _course != None: + tab += "course" + if _ethn != None: + tab += "cuisine" + if _time != None: + tab += "total_time" + if _avoid_ingr != None: + tab += "ingredients" + test = len(tab) + + i = 0 + + if tab.find("diet") != -1 || tab.find("cuisine") != -1: + for i in range(len(tab) - 1): + if tab[i] == "name": + tmp = _name + if tab[i] == "ingredients": + tmp = _ingr + if tab[i] == "diet": + tmp = _diet + if tab[i] == "course": + tmp = _course + if tab[i] == "cuisine": + tmp = _cuisine + if tab[i] == "total_time": + tmp = _time + + if i == (test - 1): + request1 += tab[i] + " != '%{tmp}%' AND " + else: + request1 += tab[i] + " = '%{tmp}%' AND " + + if tab[len(tab) - 1] == "name": + tmp = _name + if tab[len(tab - 1)] == "ingredients": + tmp = _ingr + if tab[len(tab - 1)] == "diet": + tmp = _diet + if tab[len(tab - 1)] == "course": + tmp = _course + if tab[len(tab - 1)] == "cuisine": + tmp = _cuisine + if tab[len(tab - 1)] == "total_time": + tmp = _time + + if i == (test - 1): + request = request1 + tab[len(tab) - 1] + "!= '%{tmp}%'" + else: + request = request1 + tab[len(tab) - 1] + "= '%{tmp}%'" + + if != None: + request += " ORDER BY " + + else: + for i in range(len(tab) - 1): + if tab[i] == "name": + tmp = _name + if tab[i] == "ingredients": + tmp = _ingr + if test != 0: + test = 2 + if tab[i] == "diet": + tmp = _diet + if tab[i] == "course": + tmp = _course + if tab[i] == "cuisine": + tmp = _cuisine + if tab[i] == "total_time": + tmp = _time + if i == (test - 1): + request1 += tab[i] + " != '%{tmp}%' AND " + request2 += tab[i] + " != '%{tmp}%' AND " + else: + request1 += tab[i] + " = '%{tmp}%' AND " + request2 += tab[i] + " = '%{tmp}% AND " + + if tab[len(tab) - 1] == "name": + tmp = _name + if tab[len(tab - 1)] == "ingredients": + tmp = _ingr + if tab[len(tab - 1)] == "diet": + tmp = _diet + if tab[len(tab - 1)] == "course": + tmp = _course + if tab[len(tab - 1)] == "cuisine": + tmp = _cuisine + if tab[len(tab - 1)] == "total_time": + tmp = _time + if i == (test - 1): + request1 += tab[len(tab) - 1] + " != '%{tmp}%'" + request2 += tab[len(tab) - 1] + " != '%{tmp}%'" + else: + request1 += tab[len(tab) - 1] + " = '%{tmp}%'" + request2 += tab[len(tab) - 1] + " = '%{tmp}%';" + + if test = : + request3 = request1 + " UNION " + request2 + + if != None: + + request = "WITH mytable AS (%{request3}%) SELECT distinct name FROM mytable ORDER BY " + + return request + ";" + -- GitLab From c6efc242b64831ceff8beed547ccf79b87b2d21d Mon Sep 17 00:00:00 2001 From: Nawel HEBRI <nawel.hebri@edu.univ-paris13.fr> Date: Sun, 29 Dec 2024 00:25:23 +0100 Subject: [PATCH 02/21] Modification de requete.py et de foodapp.py --- foodApp.py | 18 +++++++++++---- requete.py | 64 ++++++++++++++++++++++++++++++++++++------------------ 2 files changed, 57 insertions(+), 25 deletions(-) diff --git a/foodApp.py b/foodApp.py index 2e8c296..93a313d 100644 --- a/foodApp.py +++ b/foodApp.py @@ -254,11 +254,22 @@ class MainWindow(QtWidgets.QMainWindow): layout.addWidget(_label_course, 1, 2) layout.addWidget(self.course_box, 1, 3) + #call function to connect to database + self.connect_DB() + #create the ethnicity dropdown box _label_ethn = QtWidgets.QLabel('Ethnicity ', self) _label_ethn.setFixedSize(60,20) self.ethn_box = QtWidgets.QComboBox() - self.ethn_box.addItems( ['Test1', 'Test2'] ) + + self.cursor.execute("""WITH mytable AS (SELECT distinct ingredients FROM ethnic UNION SELECT distinct ingredients FROM general) SELECET distinct ingredients FROM mytable;""") + self.conn.commit() + rows = self.cursor.fetchall() + + for i in range(len(rows)): + rows[i] = "'" + rows[i] + "'" + + self.ethn_box.addItems(rows) self.ethn_box.setCurrentIndex( -1 ) layout.addWidget(_label_ethn, 2, 0) layout.addWidget(self.ethn_box, 2, 1) @@ -276,7 +287,7 @@ class MainWindow(QtWidgets.QMainWindow): _label_avoid = QtWidgets.QLabel('Avoid ', self) _label_avoid.setFixedSize(50,20) self.av_box = QtWidgets.QComboBox() - self.av_box.addItems( ['Test1', 'Test2'] ) + self.av_box.addItems( rows[i]) self.av_box.setCurrentIndex( -1 ) layout.addWidget(_label_avoid, 3, 0) layout.addWidget(self.av_box, 3, 1) @@ -286,8 +297,7 @@ class MainWindow(QtWidgets.QMainWindow): self.go_button.clicked.connect(self.button_Go) layout.addWidget(self.go_button, 3, 3) - #call function to connect to database - self.connect_DB() + self.show() diff --git a/requete.py b/requete.py index 24252cc..641f2bb 100644 --- a/requete.py +++ b/requete.py @@ -37,12 +37,18 @@ def request(): if tab[i] == "cuisine": tmp = _cuisine if tab[i] == "total_time": - tmp = _time - - if i == (test - 1): - request1 += tab[i] + " != '%{tmp}%' AND " + #transform string to minutes + time = int(re.findall(r'\d', _time)) + tmp = time * 60 + + if tab[i] == "ingredients" && i != (test - 1): + #with ingredient case + request1 += tab[i] + " LIKE '%{tmp}%' AND " + elif tab[i] == "ingredients" && i == (test - 1): + #avoid ingredient case + request1 += tab[i] + " NOT LIKE '%{tmp}%' AND " else: - request1 += tab[i] + " = '%{tmp}%' AND " + request1 += tab[i] + " = '{tmp}' AND " if tab[len(tab) - 1] == "name": tmp = _name @@ -57,10 +63,14 @@ def request(): if tab[len(tab - 1)] == "total_time": tmp = _time - if i == (test - 1): - request = request1 + tab[len(tab) - 1] + "!= '%{tmp}%'" + if tab[len(tab) - 1] == "ingredients" && i != (test - 1): + #with ingredient case + request1 += tab[len(tab) - 1] + " LIKE '%{tmp}%'" + elif tab[len(tab) - 1] == "ingredients" && i == (test - 1): + #avoid ingredient case + request1 += tab[len(tab) - 1] + " NOT LIKE '%{tmp}%'" else: - request = request1 + tab[len(tab) - 1] + "= '%{tmp}%'" + request1 += tab[len(tab)] + " = '{tmp}'" if != None: request += " ORDER BY " @@ -81,12 +91,18 @@ def request(): tmp = _cuisine if tab[i] == "total_time": tmp = _time - if i == (test - 1): - request1 += tab[i] + " != '%{tmp}%' AND " - request2 += tab[i] + " != '%{tmp}%' AND " + + if tab[i] == "ingredients" && i != (test - 1): + #with ingredient case + request1 += tab[i] + " LIKE '%{tmp}%' AND " + request2 += tab[i] + " LIKE '%{tmp}%' AND " + elif tab[i] == "ingredients" && i == (test - 1): + #avoid ingredient case + request1 += tab[i] + " NOT LIKE '%{tmp}%' AND " + request1 += tab[i] + " NOT LIKE '%{tmp}%' AND " else: - request1 += tab[i] + " = '%{tmp}%' AND " - request2 += tab[i] + " = '%{tmp}% AND " + request1 += tab[i] + " = '{tmp}' AND " + request2 += tab[i] + " = '{tmp}' AND " if tab[len(tab) - 1] == "name": tmp = _name @@ -100,19 +116,25 @@ def request(): tmp = _cuisine if tab[len(tab - 1)] == "total_time": tmp = _time - if i == (test - 1): - request1 += tab[len(tab) - 1] + " != '%{tmp}%'" - request2 += tab[len(tab) - 1] + " != '%{tmp}%'" + + if tab[i] == "ingredients" && i != (test - 1): + #with ingredient case + request1 += tab[len(tab) - 1] + " LIKE '%{tmp}%'" + request2 += tab[len(tab) - 1] + " LIKE '%{tmp}%'" + elif tab[i] == "ingredients" && i == (test - 1): + #avoid ingredient case + request1 += tab[len(tab) - 1] + " NOT LIKE '%{tmp}%'" + request1 += tab[len(tab) - 1] + " NOT LIKE '%{tmp}%'" else: - request1 += tab[len(tab) - 1] + " = '%{tmp}%'" - request2 += tab[len(tab) - 1] + " = '%{tmp}%';" + request1 += tab[len(tab) - 1] + " = '{tmp}'" + request2 += tab[len(tab) - 1] + " = '{tmp}'" - if test = : - request3 = request1 + " UNION " + request2 + + request3 = request1 + " UNION " + request2 if != None: - request = "WITH mytable AS (%{request3}%) SELECT distinct name FROM mytable ORDER BY " + request = "WITH mytable AS ({request3} SELECT distinct name FROM mytable ORDER BY " return request + ";" -- GitLab From dd31f56aa8dd0e7c4310ffa263ce8534a337a848 Mon Sep 17 00:00:00 2001 From: Nawel HEBRI <nawel.hebri@edu.univ-paris13.fr> Date: Sun, 29 Dec 2024 00:35:33 +0100 Subject: [PATCH 03/21] Update requete et foodapp files --- foodApp.py | 13 +++++++++++-- requete.py | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/foodApp.py b/foodApp.py index 93a313d..df4b837 100644 --- a/foodApp.py +++ b/foodApp.py @@ -287,7 +287,7 @@ class MainWindow(QtWidgets.QMainWindow): _label_avoid = QtWidgets.QLabel('Avoid ', self) _label_avoid.setFixedSize(50,20) self.av_box = QtWidgets.QComboBox() - self.av_box.addItems( rows[i]) + self.av_box.addItems(rows) self.av_box.setCurrentIndex( -1 ) layout.addWidget(_label_avoid, 3, 0) layout.addWidget(self.av_box, 3, 1) @@ -352,7 +352,10 @@ class MainWindow(QtWidgets.QMainWindow): self.cursor.execute(query_ingr) self.conn.commit() - if + if _avoid_ingr != None: + query_avoid_ingr = noingredient_query(table_ingr, '', table_avoid_ingr, _avoid_ingr) + self.cursor.execute(query_avoid_ingr) + self.conn.commit() if _ethn != None: @@ -366,6 +369,12 @@ class MainWindow(QtWidgets.QMainWindow): self.conn.commit() rows += self.cursor.fetchall() + + #AVEC METHODE 2 + # query = request(_name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr) + #self.cursor.execute(query) + #self.conn.commit() + #rows = self.cursor.fecthall() if _hops>= 1 : self.cursor.execute(""f""" SELECT """) diff --git a/requete.py b/requete.py index 641f2bb..a7765bc 100644 --- a/requete.py +++ b/requete.py @@ -1,4 +1,4 @@ -def request(): +def request(name, ingr, diet, course, ethn, time, avoid_ingr): request1 = "SELECT distinct name FROM ethnic WHERE " request2 = "SELECT distinct name FROM general WHERE " -- GitLab From f7906fe4fcb8dde80b000c3e8522c159bb969719 Mon Sep 17 00:00:00 2001 From: Nawel HEBRI <nawel.hebri@edu.univ-paris13.fr> Date: Sun, 29 Dec 2024 18:05:45 +0100 Subject: [PATCH 04/21] Modif sur requete.py et foodapp.py --- foodApp.py | 69 ++++++++++++++++++++-------------------- requete.py | 93 +++++++++++++++++++----------------------------------- 2 files changed, 68 insertions(+), 94 deletions(-) diff --git a/foodApp.py b/foodApp.py index df4b837..4eaf8e7 100644 --- a/foodApp.py +++ b/foodApp.py @@ -326,52 +326,53 @@ class MainWindow(QtWidgets.QMainWindow): _ethn = str(self.ethn_box.currentText()) _time = str(self.time_box.currentText()) _avoid_ingr = str(self.av_box.currentText()) + _sort_time = str(self.sort_button.currentText()) rows = [] - ethnic = "ethnic" - general = "general" + # ethnic = "ethnic" + #general = "general" - if _time != None: - if _time == "< 1 hour" | _time == "< 2 hours" | _time == "< 3 hours" | _time == "4 hours": - #verifier si ça marche - _time = int(re.findall(r'\d', _time)) - _time = _time * 60 - - query_max = maximum_query(ethnic, general, table_max, _time) - self.cursor.execute(query_max) - self.conn.commit() - - if _course != None: - query_course = course_query(table_max, '', table_course, _course) - self.cursor.execute(query_course) - self.conn.commit() + #if _time != None: + # if _time == "< 1 hour" | _time == "< 2 hours" | _time == "< 3 hours" | _time == "4 hours": + # #verifier si ça marche + # _time = int(re.findall(r'\d', _time)) + # _time = _time * 60 + # + # query_max = maximum_query(ethnic, general, table_max, _time) + # self.cursor.execute(query_max) + # self.conn.commit() + # + # if _course != None: + # query_course = course_query(table_max, '', table_course, _course) + # self.cursor.execute(query_course) + # self.conn.commit() - if _ingr != None: - query_ingr = ingredient_query(table_course, '', table_ingr, _ingr) - self.cursor.execute(query_ingr) - self.conn.commit() + # if _ingr != None: + # query_ingr = ingredient_query(table_course, '', table_ingr, _ingr) + # self.cursor.execute(query_ingr) + # self.conn.commit() - if _avoid_ingr != None: - query_avoid_ingr = noingredient_query(table_ingr, '', table_avoid_ingr, _avoid_ingr) - self.cursor.execute(query_avoid_ingr) - self.conn.commit() + # if _avoid_ingr != None: + # query_avoid_ingr = noingredient_query(table_ingr, '', table_avoid_ingr, _avoid_ingr) + # self.cursor.execute(query_avoid_ingr) + # self.conn.commit() - if _ethn != None: - query_ethn = cuisine_query(table_ingr, table_ethn, _ethn) - self.cursor.execute(query_ethn) - self.conn.commit() + # if _ethn != None: + # query_ethn = cuisine_query(table_ingr, table_ethn, _ethn) + # self.cursor.execute(query_ethn) + # self.conn.commit() - if _diet != None: - query_diet = diet_query(table_ethn, table_diet, _diet) - self.cursor.execute(query_diet) - self.conn.commit() + # if _diet != None: + # query_diet = diet_query(table_ethn, table_diet, _diet) + # self.cursor.execute(query_diet) + # self.conn.commit() - rows += self.cursor.fetchall() + #rows += self.cursor.fetchall() #AVEC METHODE 2 - # query = request(_name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr) + # query = request(_name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, _sort_alph) #self.cursor.execute(query) #self.conn.commit() #rows = self.cursor.fecthall() diff --git a/requete.py b/requete.py index a7765bc..be47c73 100644 --- a/requete.py +++ b/requete.py @@ -1,4 +1,4 @@ -def request(name, ingr, diet, course, ethn, time, avoid_ingr): +def request(name, ingr, diet, course, ethn, time, avoid_ingr, sort_time, sort_alph): request1 = "SELECT distinct name FROM ethnic WHERE " request2 = "SELECT distinct name FROM general WHERE " @@ -26,20 +26,8 @@ def request(name, ingr, diet, course, ethn, time, avoid_ingr): if tab.find("diet") != -1 || tab.find("cuisine") != -1: for i in range(len(tab) - 1): - if tab[i] == "name": - tmp = _name - if tab[i] == "ingredients": - tmp = _ingr - if tab[i] == "diet": - tmp = _diet - if tab[i] == "course": - tmp = _course - if tab[i] == "cuisine": - tmp = _cuisine - if tab[i] == "total_time": - #transform string to minutes - time = int(re.findall(r'\d', _time)) - tmp = time * 60 + + tmp = verification(tab[i]) if tab[i] == "ingredients" && i != (test - 1): #with ingredient case @@ -50,18 +38,7 @@ def request(name, ingr, diet, course, ethn, time, avoid_ingr): else: request1 += tab[i] + " = '{tmp}' AND " - if tab[len(tab) - 1] == "name": - tmp = _name - if tab[len(tab - 1)] == "ingredients": - tmp = _ingr - if tab[len(tab - 1)] == "diet": - tmp = _diet - if tab[len(tab - 1)] == "course": - tmp = _course - if tab[len(tab - 1)] == "cuisine": - tmp = _cuisine - if tab[len(tab - 1)] == "total_time": - tmp = _time + tmp = verification(tab[len(tab) - 1]) if tab[len(tab) - 1] == "ingredients" && i != (test - 1): #with ingredient case @@ -73,24 +50,11 @@ def request(name, ingr, diet, course, ethn, time, avoid_ingr): request1 += tab[len(tab)] + " = '{tmp}'" if != None: - request += " ORDER BY " + request = request1 + " ORDER BY name" else: for i in range(len(tab) - 1): - if tab[i] == "name": - tmp = _name - if tab[i] == "ingredients": - tmp = _ingr - if test != 0: - test = 2 - if tab[i] == "diet": - tmp = _diet - if tab[i] == "course": - tmp = _course - if tab[i] == "cuisine": - tmp = _cuisine - if tab[i] == "total_time": - tmp = _time + tmp = verification(tab[i]) if tab[i] == "ingredients" && i != (test - 1): #with ingredient case @@ -104,18 +68,7 @@ def request(name, ingr, diet, course, ethn, time, avoid_ingr): request1 += tab[i] + " = '{tmp}' AND " request2 += tab[i] + " = '{tmp}' AND " - if tab[len(tab) - 1] == "name": - tmp = _name - if tab[len(tab - 1)] == "ingredients": - tmp = _ingr - if tab[len(tab - 1)] == "diet": - tmp = _diet - if tab[len(tab - 1)] == "course": - tmp = _course - if tab[len(tab - 1)] == "cuisine": - tmp = _cuisine - if tab[len(tab - 1)] == "total_time": - tmp = _time + tmp = verification(tab[len(tab) - 1]) if tab[i] == "ingredients" && i != (test - 1): #with ingredient case @@ -129,12 +82,32 @@ def request(name, ingr, diet, course, ethn, time, avoid_ingr): request1 += tab[len(tab) - 1] + " = '{tmp}'" request2 += tab[len(tab) - 1] + " = '{tmp}'" - - request3 = request1 + " UNION " + request2 - - if != None: - - request = "WITH mytable AS ({request3} SELECT distinct name FROM mytable ORDER BY " + request1 += " ORDER BY name" + request2 += " ORDER BY name" + request3 = request1 + " UNION " + request2 + if != None && == "": + request = "WITH mytable AS ({request3} SELECT distinct name FROM mytable ORDER BY total_time ASC" + elif != None && =="": + request = "WITH mytable AS ({request3} SELECT distinct name FROM mytable ORDER BY total_time DESC" + return request + ";" + + def verification(tab): + if tab == "name": + tmp = _name + elif tab == "ingredients": + tmp = _ingr + elif tab == "diet": + tmp = _diet + elif tab == "course": + tmp = _course + elif tab == "cuisine": + tmp = _cuisine + else tab == "total_time": + #transform list to string to minutes (join concatenates) + time = int(''.join(re.findall(r'\d', _time))) + tmp = time * 60 + + return tmp -- GitLab From 066afc12e8219cb2a04a1a81d40cda8c990dc43e Mon Sep 17 00:00:00 2001 From: Nawel HEBRI <nawel.hebri@edu.univ-paris13.fr> Date: Sun, 29 Dec 2024 18:15:49 +0100 Subject: [PATCH 05/21] "modif" --- foodApp.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/foodApp.py b/foodApp.py index 4eaf8e7..3c7265e 100644 --- a/foodApp.py +++ b/foodApp.py @@ -296,8 +296,6 @@ class MainWindow(QtWidgets.QMainWindow): self.go_button = QtWidgets.QPushButton("Find !") self.go_button.clicked.connect(self.button_Go) layout.addWidget(self.go_button, 3, 3) - - self.show() @@ -327,6 +325,7 @@ class MainWindow(QtWidgets.QMainWindow): _time = str(self.time_box.currentText()) _avoid_ingr = str(self.av_box.currentText()) _sort_time = str(self.sort_button.currentText()) + _sort_alph = str(self.sort) rows = [] -- GitLab From 7e346647a6f37fe53ac4585f85023af79589e146 Mon Sep 17 00:00:00 2001 From: Nawel HEBRI <nawel.hebri@edu.univ-paris13.fr> Date: Sun, 29 Dec 2024 19:31:02 +0100 Subject: [PATCH 06/21] Update requete.py --- requete.py | 66 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 51 insertions(+), 15 deletions(-) diff --git a/requete.py b/requete.py index be47c73..3c60313 100644 --- a/requete.py +++ b/requete.py @@ -1,8 +1,9 @@ -def request(name, ingr, diet, course, ethn, time, avoid_ingr, sort_time, sort_alph): +def request(_name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, _sort_alph): request1 = "SELECT distinct name FROM ethnic WHERE " request2 = "SELECT distinct name FROM general WHERE " tab = [] + tab_order = [] test = 0 @@ -21,13 +22,17 @@ def request(name, ingr, diet, course, ethn, time, avoid_ingr, sort_time, sort_al if _avoid_ingr != None: tab += "ingredients" test = len(tab) + if _sort_alph != None: + tab_order += "sort_alph" + if _sort_time != None: + tab_order += "sort_time" i = 0 if tab.find("diet") != -1 || tab.find("cuisine") != -1: for i in range(len(tab) - 1): - tmp = verification(tab[i]) + tmp = verification(tab[i], _name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, _sort_alph) if tab[i] == "ingredients" && i != (test - 1): #with ingredient case @@ -38,7 +43,7 @@ def request(name, ingr, diet, course, ethn, time, avoid_ingr, sort_time, sort_al else: request1 += tab[i] + " = '{tmp}' AND " - tmp = verification(tab[len(tab) - 1]) + tmp = verification(tab[len(tab) - 1], _name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, _sort_alph) if tab[len(tab) - 1] == "ingredients" && i != (test - 1): #with ingredient case @@ -49,12 +54,28 @@ def request(name, ingr, diet, course, ethn, time, avoid_ingr, sort_time, sort_al else: request1 += tab[len(tab)] + " = '{tmp}'" - if != None: - request = request1 + " ORDER BY name" + request1 += " ORDER BY " + for i in range(len(tab_order)): + if tab_order[i] == "sort_alph": + if _sort_alph == "ascendant": # A MODIFIER + request1 += "name ASC" + elif _sort_alph == "descendant": # A MODIFIER + request1 += "name DESC" + + if i < len(tab_order) - 1: + request1 += ", " + + if tab_order[i] == "sort_time": + if _sort_time == "ascendant": # A MODIFIER + request1 += "total_time ASC" + elif _sort_time == "descendant": # A MODIFIER + request1 += "total_time DESC" + + request = request1 else: for i in range(len(tab) - 1): - tmp = verification(tab[i]) + tmp = verification(tab[i], _name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, _sort_alph) if tab[i] == "ingredients" && i != (test - 1): #with ingredient case @@ -68,7 +89,7 @@ def request(name, ingr, diet, course, ethn, time, avoid_ingr, sort_time, sort_al request1 += tab[i] + " = '{tmp}' AND " request2 += tab[i] + " = '{tmp}' AND " - tmp = verification(tab[len(tab) - 1]) + tmp = verification(tab[len(tab) - 1], _name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, _sort_alph) if tab[i] == "ingredients" && i != (test - 1): #with ingredient case @@ -82,18 +103,30 @@ def request(name, ingr, diet, course, ethn, time, avoid_ingr, sort_time, sort_al request1 += tab[len(tab) - 1] + " = '{tmp}'" request2 += tab[len(tab) - 1] + " = '{tmp}'" - request1 += " ORDER BY name" - request2 += " ORDER BY name" request3 = request1 + " UNION " + request2 + + if tab_order != None: + request = "WITH mytable AS ({request3} SELECT distinct name FROM mytable ORDER BY " - if != None && == "": - request = "WITH mytable AS ({request3} SELECT distinct name FROM mytable ORDER BY total_time ASC" - elif != None && =="": - request = "WITH mytable AS ({request3} SELECT distinct name FROM mytable ORDER BY total_time DESC" + for i in range(len(tab_order)): + if tab_order[i] == "sort_alph": + if _sort_alph == "ascendant": # A MODIFIER + request += "name ASC" + elif _sort_alph == "descendant": #A MODIFIER + request += "name DESC" + + if i < len(tab_order) - 1: + request += ", " + + if tab_order[i] == "sort_time": + if _sort_time == "ascendant": #A MODIFIER + request += "total_time ASC" + elif _sort_time == "descendant": #A MODIFIER + request += "total_time DESC" return request + ";" - def verification(tab): + def verification(tab, _name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, _sort_alph): if tab == "name": tmp = _name elif tab == "ingredients": @@ -107,7 +140,10 @@ def request(name, ingr, diet, course, ethn, time, avoid_ingr, sort_time, sort_al else tab == "total_time": #transform list to string to minutes (join concatenates) time = int(''.join(re.findall(r'\d', _time))) - tmp = time * 60 + if time != 30: + tmp = time * 60 + else: + tmp = time return tmp -- GitLab From f7aa136d86b6264078a452077988cca09821f18d Mon Sep 17 00:00:00 2001 From: Nawel HEBRI <nawel.hebri@edu.univ-paris13.fr> Date: Sun, 29 Dec 2024 19:38:40 +0100 Subject: [PATCH 07/21] "mdif again" --- foodApp.py | 9 +++++---- requete.py | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/foodApp.py b/foodApp.py index 2a02fca..f4091bd 100644 --- a/foodApp.py +++ b/foodApp.py @@ -3,6 +3,7 @@ import psycopg2 from PyQt5 import (QtGui, QtCore, QtWidgets, QtGui) from PyQt5.QtWidgets import(QComboBox, QApplication, QCompleter, QGridLayout) from PyQt5.QtCore import Qt +from requete.py import * # /!\ IMPORTANT /!\ #Créer la table user au préable comme suit : @@ -381,10 +382,10 @@ class MainWindow(QtWidgets.QMainWindow): #rows += self.cursor.fetchall() #AVEC METHODE 2 - # query = request(_name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, _sort_alph) - #self.cursor.execute(query) - #self.conn.commit() - #rows = self.cursor.fecthall() + query = request(_name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, _sort_alph) + self.cursor.execute(query) + self.conn.commit() + rows = self.cursor.fecthall() if _hops>= 1 : self.cursor.execute(""f""" SELECT """) diff --git a/requete.py b/requete.py index 3c60313..21a2bcd 100644 --- a/requete.py +++ b/requete.py @@ -1,6 +1,6 @@ def request(_name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, _sort_alph): - request1 = "SELECT distinct name FROM ethnic WHERE " - request2 = "SELECT distinct name FROM general WHERE " + request1 = "SELECT distinct name, image FROM ethnic WHERE " + request2 = "SELECT distinct name, image FROM general WHERE " tab = [] tab_order = [] @@ -106,7 +106,7 @@ def request(_name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, request3 = request1 + " UNION " + request2 if tab_order != None: - request = "WITH mytable AS ({request3} SELECT distinct name FROM mytable ORDER BY " + request = "WITH mytable AS ({request3} SELECT distinct name, image FROM mytable ORDER BY " for i in range(len(tab_order)): if tab_order[i] == "sort_alph": -- GitLab From 8d9bb9ad9f6a01afa85b3b711fd27d7116f6d30f Mon Sep 17 00:00:00 2001 From: Nawel HEBRI <nawel.hebri@edu.univ-paris13.fr> Date: Sun, 29 Dec 2024 20:36:32 +0100 Subject: [PATCH 08/21] update requete.py --- requete.py | 128 +++++++++++++++++++++++++++++------------------------ 1 file changed, 71 insertions(+), 57 deletions(-) diff --git a/requete.py b/requete.py index 21a2bcd..2658bf7 100644 --- a/requete.py +++ b/requete.py @@ -1,3 +1,34 @@ +import re + +def verification(tab, _name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, _sort_alph): + tmp = None + if tab == "name": + tmp = _name + elif tab == "ingredients": + tmp = _ingr + elif tab == "diet": + tmp = _diet + elif tab == "course": + tmp = _course + elif tab == "cuisine": + tmp = _ethn + elif tab == "total_time": + #transform list to string to minutes (join concatenates) + time = int(''.join(re.findall(r'\d', _time))) + if time != 30: + tmp = time * 60 + else: + tmp = time + + return tmp + +def find_list(tab, val_to_find): + i = 0 + for i in range(len(tab)): + if tab[i] == val_to_find: + return 0 + return -1 + def request(_name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, _sort_alph): request1 = "SELECT distinct name, image FROM ethnic WHERE " request2 = "SELECT distinct name, image FROM general WHERE " @@ -8,36 +39,36 @@ def request(_name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, test = 0 if _name != None: - tab += "name" + tab.append("name") if _ingr != None: - tab += "ingredients": + tab.append("ingredients") if _diet != None: - tab += "diet" + tab.append("diet") if _course != None: - tab += "course" + tab.append("course") if _ethn != None: - tab += "cuisine" + tab.append("cuisine") if _time != None: - tab += "total_time" + tab.append("total_time") if _avoid_ingr != None: - tab += "ingredients" + tab.append("ingredients") test = len(tab) if _sort_alph != None: - tab_order += "sort_alph" + tab_order.append("sort_alph") if _sort_time != None: - tab_order += "sort_time" + tab_order.append("sort_time") i = 0 - if tab.find("diet") != -1 || tab.find("cuisine") != -1: + if find_list(tab, "diet") != -1 or find_list(tab, "cuisine") != -1: for i in range(len(tab) - 1): tmp = verification(tab[i], _name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, _sort_alph) - if tab[i] == "ingredients" && i != (test - 1): + if tab[i] == "ingredients" and i != (test - 1): #with ingredient case request1 += tab[i] + " LIKE '%{tmp}%' AND " - elif tab[i] == "ingredients" && i == (test - 1): + elif tab[i] == "ingredients" and i == (test - 1): #avoid ingredient case request1 += tab[i] + " NOT LIKE '%{tmp}%' AND " else: @@ -45,43 +76,43 @@ def request(_name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, tmp = verification(tab[len(tab) - 1], _name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, _sort_alph) - if tab[len(tab) - 1] == "ingredients" && i != (test - 1): + if tab[len(tab) - 1] == "ingredients" and i != (test - 1): #with ingredient case request1 += tab[len(tab) - 1] + " LIKE '%{tmp}%'" - elif tab[len(tab) - 1] == "ingredients" && i == (test - 1): + elif tab[len(tab) - 1] == "ingredients" and i == (test - 1): #avoid ingredient case request1 += tab[len(tab) - 1] + " NOT LIKE '%{tmp}%'" else: - request1 += tab[len(tab)] + " = '{tmp}'" + request1 += tab[len(tab) - 1] + " = '{tmp}'" request1 += " ORDER BY " for i in range(len(tab_order)): if tab_order[i] == "sort_alph": - if _sort_alph == "ascendant": # A MODIFIER - request1 += "name ASC" - elif _sort_alph == "descendant": # A MODIFIER - request1 += "name DESC" + if _sort_alph == "ascendant":# A MODIFIER + request1 += "name ASC" + elif _sort_alph == "descendant":# A MODIFIER + request1 += "name DESC" - if i < len(tab_order) - 1: - request1 += ", " + if i < len(tab_order) - 1: + request1 += ", " if tab_order[i] == "sort_time": if _sort_time == "ascendant": # A MODIFIER - request1 += "total_time ASC" - elif _sort_time == "descendant": # A MODIFIER - request1 += "total_time DESC" + request1 += "total_time ASC" + elif _sort_time == "descendant": # A MODIFIER + request1 += "total_time DESC" request = request1 - + else: for i in range(len(tab) - 1): tmp = verification(tab[i], _name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, _sort_alph) - if tab[i] == "ingredients" && i != (test - 1): + if tab[i] == "ingredients" and i != (test - 1): #with ingredient case request1 += tab[i] + " LIKE '%{tmp}%' AND " request2 += tab[i] + " LIKE '%{tmp}%' AND " - elif tab[i] == "ingredients" && i == (test - 1): + elif tab[i] == "ingredients" and i == (test - 1): #avoid ingredient case request1 += tab[i] + " NOT LIKE '%{tmp}%' AND " request1 += tab[i] + " NOT LIKE '%{tmp}%' AND " @@ -91,11 +122,11 @@ def request(_name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, tmp = verification(tab[len(tab) - 1], _name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, _sort_alph) - if tab[i] == "ingredients" && i != (test - 1): + if tab[i] == "ingredients" and i != (test - 1): #with ingredient case request1 += tab[len(tab) - 1] + " LIKE '%{tmp}%'" request2 += tab[len(tab) - 1] + " LIKE '%{tmp}%'" - elif tab[i] == "ingredients" && i == (test - 1): + elif tab[i] == "ingredients" and i == (test - 1): #avoid ingredient case request1 += tab[len(tab) - 1] + " NOT LIKE '%{tmp}%'" request1 += tab[len(tab) - 1] + " NOT LIKE '%{tmp}%'" @@ -111,39 +142,22 @@ def request(_name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, for i in range(len(tab_order)): if tab_order[i] == "sort_alph": if _sort_alph == "ascendant": # A MODIFIER - request += "name ASC" - elif _sort_alph == "descendant": #A MODIFIER - request += "name DESC" + request += "name ASC" + elif _sort_alph == "descendant": #A MODIFIER + request += "name DESC" - if i < len(tab_order) - 1: - request += ", " + if i < len(tab_order) - 1: + request += ", " if tab_order[i] == "sort_time": if _sort_time == "ascendant": #A MODIFIER - request += "total_time ASC" - elif _sort_time == "descendant": #A MODIFIER - request += "total_time DESC" + request += "total_time ASC" + elif _sort_time == "descendant": #A MODIFIER + request += "total_time DESC" return request + ";" - def verification(tab, _name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, _sort_alph): - if tab == "name": - tmp = _name - elif tab == "ingredients": - tmp = _ingr - elif tab == "diet": - tmp = _diet - elif tab == "course": - tmp = _course - elif tab == "cuisine": - tmp = _cuisine - else tab == "total_time": - #transform list to string to minutes (join concatenates) - time = int(''.join(re.findall(r'\d', _time))) - if time != 30: - tmp = time * 60 - else: - tmp = time - return tmp - + +query = request(None, "zucchini", None, None, None, "45", None, None, "ascendant") +print(query) -- GitLab From 4d46ae07d0eefed1d1319d3408a01e4e1ad6d24f Mon Sep 17 00:00:00 2001 From: Lina MEHIDI <lina.mehidi@edu.univ-paris13.fr> Date: Sun, 29 Dec 2024 18:43:36 +0100 Subject: [PATCH 09/21] hash function and likes schemas --- ethnic_likes-schema.sql | 7 +++++++ general_likes-schema.sql | 7 +++++++ hashing.py | 6 ++++++ 3 files changed, 20 insertions(+) create mode 100644 ethnic_likes-schema.sql create mode 100644 general_likes-schema.sql create mode 100644 hashing.py diff --git a/ethnic_likes-schema.sql b/ethnic_likes-schema.sql new file mode 100644 index 0000000..8bfc988 --- /dev/null +++ b/ethnic_likes-schema.sql @@ -0,0 +1,7 @@ +CREATE TABLE IF NOT EXISTS likes( + username VARCHAR(30) NOT NULL, + name VARCHAR(200) NOT NULL, + PRIMARY KEY(username, name) + FOREIGN KEY(name) references ethnic, + FOREIGN KEY(username) references users +); diff --git a/general_likes-schema.sql b/general_likes-schema.sql new file mode 100644 index 0000000..fee3070 --- /dev/null +++ b/general_likes-schema.sql @@ -0,0 +1,7 @@ +CREATE TABLE IF NOT EXISTS likes( + username VARCHAR(30) NOT NULL, + name VARCHAR(200) NOT NULL, + PRIMARY KEY(username, name) + FOREIGN KEY(name) references general, + FOREIGN KEY(username) references users +); diff --git a/hashing.py b/hashing.py new file mode 100644 index 0000000..1cda213 --- /dev/null +++ b/hashing.py @@ -0,0 +1,6 @@ +import hashlib + +def hash_password(pswd) : + hash=hashlib.sha256(pswd.encode('utf-8')) + hash=hash.hexdigest() + return hash -- GitLab From fd97b6395845694adf86274bfdbef1a72650372d Mon Sep 17 00:00:00 2001 From: Lina MEHIDI <lina.mehidi@edu.univ-paris13.fr> Date: Sun, 29 Dec 2024 18:50:46 +0100 Subject: [PATCH 10/21] ajustements --- connect-to-psql.py | 7 +++++++ ethnic_likes-schema.sql | 4 ++-- general_likes-schema.sql | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/connect-to-psql.py b/connect-to-psql.py index a52cf33..e3c52a5 100644 --- a/connect-to-psql.py +++ b/connect-to-psql.py @@ -65,6 +65,13 @@ if conn : table_name = 'users' create_table(conn, table_name) + #as well as the likes table for general and ethnic + table_name= 'general_likes' + create_table(conn, table_name) + + table_name= 'ethnic_likes' + create_table(conn, table_name) + #then we make all the insert statements of the general table table_name = 'general' file_name = table_name + '_recipes.csv' diff --git a/ethnic_likes-schema.sql b/ethnic_likes-schema.sql index 8bfc988..23c35ca 100644 --- a/ethnic_likes-schema.sql +++ b/ethnic_likes-schema.sql @@ -1,7 +1,7 @@ -CREATE TABLE IF NOT EXISTS likes( +CREATE TABLE IF NOT EXISTS ethnic_likes( username VARCHAR(30) NOT NULL, name VARCHAR(200) NOT NULL, - PRIMARY KEY(username, name) + PRIMARY KEY(username, name), FOREIGN KEY(name) references ethnic, FOREIGN KEY(username) references users ); diff --git a/general_likes-schema.sql b/general_likes-schema.sql index fee3070..8c1b13f 100644 --- a/general_likes-schema.sql +++ b/general_likes-schema.sql @@ -1,7 +1,7 @@ -CREATE TABLE IF NOT EXISTS likes( +CREATE TABLE IF NOT EXISTS general_likes( username VARCHAR(30) NOT NULL, name VARCHAR(200) NOT NULL, - PRIMARY KEY(username, name) + PRIMARY KEY(username, name), FOREIGN KEY(name) references general, FOREIGN KEY(username) references users ); -- GitLab From 4f6b673cd6b9cd4415f43f34ee77b952f131acfc Mon Sep 17 00:00:00 2001 From: Wer0x <152016645+Wer0x@users.noreply.github.com> Date: Sun, 29 Dec 2024 20:26:56 +0100 Subject: [PATCH 11/21] =?UTF-8?q?Ajout=20des=20choix=20des=20tri=20ascenda?= =?UTF-8?q?nt=20et=20descendant=20pour=20time=20et=20ordre=20alphabetique,?= =?UTF-8?q?=20modification=20du=20bouton=20'time'=20on=20peut=20maintenant?= =?UTF-8?q?=20=C3=A9crire=20dedans,=20r=C3=A9ajustement=20de=20l'interface?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- foodApp.py | 124 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 92 insertions(+), 32 deletions(-) diff --git a/foodApp.py b/foodApp.py index f4091bd..0f0c47a 100644 --- a/foodApp.py +++ b/foodApp.py @@ -1,7 +1,7 @@ import sys import psycopg2 from PyQt5 import (QtGui, QtCore, QtWidgets, QtGui) -from PyQt5.QtWidgets import(QComboBox, QApplication, QCompleter, QGridLayout) +from PyQt5.QtWidgets import(QComboBox, QApplication, QCompleter, QGridLayout, QRadioButton, QButtonGroup) from PyQt5.QtCore import Qt from requete.py import * @@ -203,19 +203,75 @@ class MainWindow(QtWidgets.QMainWindow): #create the main window main = QtWidgets.QWidget() self.setCentralWidget(main) - main.setLayout(QtWidgets.QVBoxLayout()) - main.setFocusPolicy(QtCore.Qt.StrongFocus) - layout = QGridLayout() - main.layout().addLayout(layout) - #create the table widget - self.tableWidget = QtWidgets.QTableWidget() - self.tableWidget.doubleClicked.connect(self.table_Click) - + main_layout = QtWidgets.QVBoxLayout() + main.setLayout(main_layout) + main.setFocusPolicy(QtCore.Qt.StrongFocus) controls_panel = QtWidgets.QHBoxLayout() - main.layout().addLayout(controls_panel) - main.layout().addWidget(self.tableWidget) + #main.layout().addLayout(controls_panel) + #main.layout().addWidget(self.tableWidget) + + #Create Radio buttons for sort + #Alphabetically Sort + alpha_layout = QtWidgets.QHBoxLayout() + alpha_label = QtWidgets.QLabel("Sort by Name ") + self.al_asc = QRadioButton("Ascending") + self.al_desc = QRadioButton("Descending") + self.al_group = QButtonGroup() + self.al_group.addButton(self.al_asc) + self.al_group.addButton(self.al_desc) + self.al_asc.setChecked(True) #Ascendant by default + alpha_layout.setSpacing(0) + alpha_layout.setContentsMargins(0, 0, 0, 0) + + #All this to align 2 f*cking radio buttons + alpha_layout.setAlignment(self.al_asc, QtCore.Qt.AlignVCenter) + alpha_layout.setAlignment(self.al_desc, QtCore.Qt.AlignVCenter) + alpha_layout.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) + + alpha_layout.addWidget(alpha_label) + alpha_layout.addWidget(self.al_asc) + alpha_layout.addWidget(self.al_desc) + + self.al_asc.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) + self.al_desc.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) + + alpha_layout.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) + + #Time Sort + time_layout = QtWidgets.QHBoxLayout() + time_label = QtWidgets.QLabel("Sort by Time ") + time_label.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) + time_label.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) + self.time_asc = QRadioButton("Ascending") + self.time_desc = QRadioButton("Descending") + self.time_group = QButtonGroup() + self.time_group.addButton(self.time_asc) + self.time_group.addButton(self.time_desc) + self.time_asc.setChecked(True) #Ascendant by default + time_layout.setSpacing(0) + time_layout.setContentsMargins(0, 0, 0, 0) + + #All this to align 2 f*cking radio buttons + self.time_asc.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) + self.time_desc.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) + + time_layout.addWidget(time_label) + time_layout.addWidget(self.time_asc) + time_layout.addWidget(self.time_desc) + + time_layout.setAlignment(self.time_asc, QtCore.Qt.AlignVCenter) + time_layout.setAlignment(self.time_desc, QtCore.Qt.AlignVCenter) + time_layout.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) + + #Adding Groups in a layout + sort_layout = QtWidgets.QVBoxLayout() + sort_layout.addLayout(alpha_layout) + sort_layout.addLayout(time_layout) + main_layout.addLayout(sort_layout) + + control_layout = QGridLayout() #create the Name dropdown box _label_name = QtWidgets.QLabel('Name', self) @@ -224,8 +280,8 @@ class MainWindow(QtWidgets.QMainWindow): self.name_box.setEditable(True) self.name_box.completer().setCompletionMode(QtWidgets.QCompleter.PopupCompletion) self.name_box.setInsertPolicy(QtWidgets.QComboBox.NoInsert) - layout.addWidget(_label_name, 0, 0) - layout.addWidget(self.name_box, 0, 1) + control_layout.addWidget(self.name_box, 0, 1) + control_layout.addWidget(_label_name, 0, 0) #create the Ingrédients dropdown box _label_ingr = QtWidgets.QLabel('Ingredients', self) @@ -234,8 +290,8 @@ class MainWindow(QtWidgets.QMainWindow): self.ingr_box.setEditable(True) self.ingr_box.completer().setCompletionMode(QtWidgets.QCompleter.PopupCompletion) self.ingr_box.setInsertPolicy(QtWidgets.QComboBox.NoInsert) - layout.addWidget(_label_ingr, 0, 2) - layout.addWidget(self.ingr_box, 0, 3) + control_layout.addWidget(_label_ingr, 0, 2) + control_layout.addWidget(self.ingr_box, 0, 3) #create the Diet dropdown box _label_diet = QtWidgets.QLabel('Diet ', self) @@ -243,8 +299,8 @@ class MainWindow(QtWidgets.QMainWindow): self.diet_box = QtWidgets.QComboBox() self.diet_box.addItems( ['Diabetic Friendly', 'Gluten Free', 'Vegetarian', 'High Protein Vegetarian', 'Non Vegeterian'] ) self.diet_box.setCurrentIndex( -1 ) - layout.addWidget(_label_diet, 1, 0) - layout.addWidget(self.diet_box, 1, 1) + control_layout.addWidget(_label_diet, 1, 0) + control_layout.addWidget(self.diet_box, 1, 1) #create the Course dropdown box _label_course = QtWidgets.QLabel('Course ', self) @@ -252,8 +308,8 @@ class MainWindow(QtWidgets.QMainWindow): self.course_box = QtWidgets.QComboBox() self.course_box.addItems( ['Breakfast', 'Lunch', 'Dinner', 'Side Dish', 'Snack', 'Main Course', 'Appetizer'] ) self.course_box.setCurrentIndex( -1 ) - layout.addWidget(_label_course, 1, 2) - layout.addWidget(self.course_box, 1, 3) + control_layout.addWidget(_label_course, 1, 2) + control_layout.addWidget(self.course_box, 1, 3) #call function to connect to database self.connect_DB() @@ -272,17 +328,21 @@ class MainWindow(QtWidgets.QMainWindow): self.ethn_box.addItems(rows) self.ethn_box.setCurrentIndex( -1 ) - layout.addWidget(_label_ethn, 2, 0) - layout.addWidget(self.ethn_box, 2, 1) + control_layout.addWidget(_label_ethn, 2, 0) + control_layout.addWidget(self.ethn_box, 2, 1) - #Create the time dropdown box + #Create the time dropdown box editable _label_time = QtWidgets.QLabel('Time ', self) _label_time.setFixedSize(50,20) self.time_box = QtWidgets.QComboBox() + self.time_box.setEditable(True) self.time_box.addItems( ['< 30 minutes', '< 1 hour', '< 2 hours', '< 3 hours', '< 4 hours'] ) + completer = QtWidgets.QCompleter(self.time_box) + completer.setCompletionMode(QtWidgets.QCompleter.PopupCompletion) + self.time_box.setCompleter(completer) self.time_box.setCurrentIndex( -1 ) - layout.addWidget(_label_time, 2, 2) - layout.addWidget(self.time_box, 2, 3) + control_layout.addWidget(_label_time, 2, 2) + control_layout.addWidget(self.time_box, 2, 3) #Create the avoid ingredient dropdown box _label_avoid = QtWidgets.QLabel('Avoid ', self) @@ -290,19 +350,19 @@ class MainWindow(QtWidgets.QMainWindow): self.av_box = QtWidgets.QComboBox() self.av_box.addItems(rows) self.av_box.setCurrentIndex( -1 ) - layout.addWidget(_label_avoid, 3, 0) - layout.addWidget(self.av_box, 3, 1) - - #create the Sort Time button - self.sort_button = QtWidgets.QPushButton("Sort by Time") - self.sort_button.clicked.connect(self.button_Sort) - layout.addWidget(self.sort_button, 3, 3) + control_layout.addWidget(_label_avoid, 3, 0) + control_layout.addWidget(self.av_box, 3, 1) #create the GO button self.go_button = QtWidgets.QPushButton("Find !") self.go_button.clicked.connect(self.button_Go) - layout.addWidget(self.go_button, 4, 2) + control_layout.addWidget(self.go_button, 4, 2) + #create the table widget + self.tableWidget = QtWidgets.QTableWidget() + self.tableWidget.doubleClicked.connect(self.table_Click) + main_layout.addWidget(self.tableWidget) + #call function to connect to database self.connect_DB() -- GitLab From 3911abbfe9e6f9b85ffc15c49314bd89bf37ca14 Mon Sep 17 00:00:00 2001 From: Nawel HEBRI <nawel.hebri@edu.univ-paris13.fr> Date: Sun, 29 Dec 2024 00:25:23 +0100 Subject: [PATCH 12/21] Modification de requete.py et de foodapp.py --- foodApp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/foodApp.py b/foodApp.py index 0f0c47a..abdc1df 100644 --- a/foodApp.py +++ b/foodApp.py @@ -348,7 +348,7 @@ class MainWindow(QtWidgets.QMainWindow): _label_avoid = QtWidgets.QLabel('Avoid ', self) _label_avoid.setFixedSize(50,20) self.av_box = QtWidgets.QComboBox() - self.av_box.addItems(rows) + self.av_box.addItems( ['Test1', 'Test2'] ) self.av_box.setCurrentIndex( -1 ) control_layout.addWidget(_label_avoid, 3, 0) control_layout.addWidget(self.av_box, 3, 1) -- GitLab From 16269745b14584d82fc94588738e3dc51141912d Mon Sep 17 00:00:00 2001 From: Nawel HEBRI <nawel.hebri@edu.univ-paris13.fr> Date: Sun, 29 Dec 2024 00:35:33 +0100 Subject: [PATCH 13/21] Update requete et foodapp files --- foodApp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/foodApp.py b/foodApp.py index abdc1df..0f0c47a 100644 --- a/foodApp.py +++ b/foodApp.py @@ -348,7 +348,7 @@ class MainWindow(QtWidgets.QMainWindow): _label_avoid = QtWidgets.QLabel('Avoid ', self) _label_avoid.setFixedSize(50,20) self.av_box = QtWidgets.QComboBox() - self.av_box.addItems( ['Test1', 'Test2'] ) + self.av_box.addItems(rows) self.av_box.setCurrentIndex( -1 ) control_layout.addWidget(_label_avoid, 3, 0) control_layout.addWidget(self.av_box, 3, 1) -- GitLab From 1a13b199e42fbe2abca5ea2b3c3ad43056a525fa Mon Sep 17 00:00:00 2001 From: Nawel HEBRI <nawel.hebri@edu.univ-paris13.fr> Date: Sun, 29 Dec 2024 00:25:23 +0100 Subject: [PATCH 14/21] Modification de requete.py et de foodapp.py --- foodApp.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/foodApp.py b/foodApp.py index 856fb4a..e2ab6f9 100644 --- a/foodApp.py +++ b/foodApp.py @@ -310,11 +310,22 @@ class MainWindow(QtWidgets.QMainWindow): control_layout.addWidget(_label_course, 1, 2) control_layout.addWidget(self.course_box, 1, 3) + #call function to connect to database + self.connect_DB() + #create the ethnicity dropdown box _label_ethn = QtWidgets.QLabel('Ethnicity ', self) _label_ethn.setFixedSize(60,20) self.ethn_box = QtWidgets.QComboBox() - self.ethn_box.addItems( ['Test1', 'Test2'] ) + + self.cursor.execute("""WITH mytable AS (SELECT distinct ingredients FROM ethnic UNION SELECT distinct ingredients FROM general) SELECET distinct ingredients FROM mytable;""") + self.conn.commit() + rows = self.cursor.fetchall() + + for i in range(len(rows)): + rows[i] = "'" + rows[i] + "'" + + self.ethn_box.addItems(rows) self.ethn_box.setCurrentIndex( -1 ) control_layout.addWidget(_label_ethn, 2, 0) control_layout.addWidget(self.ethn_box, 2, 1) @@ -336,7 +347,7 @@ class MainWindow(QtWidgets.QMainWindow): _label_avoid = QtWidgets.QLabel('Avoid ', self) _label_avoid.setFixedSize(50,20) self.av_box = QtWidgets.QComboBox() - self.av_box.addItems( ['Test1', 'Test2'] ) + self.av_box.addItems( rows[i]) self.av_box.setCurrentIndex( -1 ) control_layout.addWidget(_label_avoid, 3, 0) control_layout.addWidget(self.av_box, 3, 1) -- GitLab From 5bbcb61046688fe629bac5bb977c5bca340a992d Mon Sep 17 00:00:00 2001 From: Nawel HEBRI <nawel.hebri@edu.univ-paris13.fr> Date: Sun, 29 Dec 2024 00:35:33 +0100 Subject: [PATCH 15/21] Update requete et foodapp files --- foodApp.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/foodApp.py b/foodApp.py index e2ab6f9..996bd48 100644 --- a/foodApp.py +++ b/foodApp.py @@ -347,7 +347,7 @@ class MainWindow(QtWidgets.QMainWindow): _label_avoid = QtWidgets.QLabel('Avoid ', self) _label_avoid.setFixedSize(50,20) self.av_box = QtWidgets.QComboBox() - self.av_box.addItems( rows[i]) + self.av_box.addItems(rows) self.av_box.setCurrentIndex( -1 ) control_layout.addWidget(_label_avoid, 3, 0) control_layout.addWidget(self.av_box, 3, 1) @@ -420,7 +420,10 @@ class MainWindow(QtWidgets.QMainWindow): self.cursor.execute(query_ingr) self.conn.commit() - if + if _avoid_ingr != None: + query_avoid_ingr = noingredient_query(table_ingr, '', table_avoid_ingr, _avoid_ingr) + self.cursor.execute(query_avoid_ingr) + self.conn.commit() if _ethn != None: @@ -434,6 +437,12 @@ class MainWindow(QtWidgets.QMainWindow): self.conn.commit() rows += self.cursor.fetchall() + + #AVEC METHODE 2 + # query = request(_name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr) + #self.cursor.execute(query) + #self.conn.commit() + #rows = self.cursor.fecthall() if _hops>= 1 : self.cursor.execute(""f""" SELECT """) -- GitLab From be707d692b37e0066fef43e5e764c30077553d5c Mon Sep 17 00:00:00 2001 From: Nawel HEBRI <nawel.hebri@edu.univ-paris13.fr> Date: Sun, 29 Dec 2024 18:05:45 +0100 Subject: [PATCH 16/21] Modif sur requete.py et foodapp.py --- foodApp.py | 69 +++++++++++++++++++++++++++--------------------------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/foodApp.py b/foodApp.py index 996bd48..c84a71a 100644 --- a/foodApp.py +++ b/foodApp.py @@ -394,52 +394,53 @@ class MainWindow(QtWidgets.QMainWindow): _ethn = str(self.ethn_box.currentText()) _time = str(self.time_box.currentText()) _avoid_ingr = str(self.av_box.currentText()) + _sort_time = str(self.sort_button.currentText()) rows = [] - ethnic = "ethnic" - general = "general" + # ethnic = "ethnic" + #general = "general" - if _time != None: - if _time == "< 1 hour" | _time == "< 2 hours" | _time == "< 3 hours" | _time == "4 hours": - #verifier si ça marche - _time = int(re.findall(r'\d', _time)) - _time = _time * 60 - - query_max = maximum_query(ethnic, general, table_max, _time) - self.cursor.execute(query_max) - self.conn.commit() - - if _course != None: - query_course = course_query(table_max, '', table_course, _course) - self.cursor.execute(query_course) - self.conn.commit() + #if _time != None: + # if _time == "< 1 hour" | _time == "< 2 hours" | _time == "< 3 hours" | _time == "4 hours": + # #verifier si ça marche + # _time = int(re.findall(r'\d', _time)) + # _time = _time * 60 + # + # query_max = maximum_query(ethnic, general, table_max, _time) + # self.cursor.execute(query_max) + # self.conn.commit() + # + # if _course != None: + # query_course = course_query(table_max, '', table_course, _course) + # self.cursor.execute(query_course) + # self.conn.commit() - if _ingr != None: - query_ingr = ingredient_query(table_course, '', table_ingr, _ingr) - self.cursor.execute(query_ingr) - self.conn.commit() + # if _ingr != None: + # query_ingr = ingredient_query(table_course, '', table_ingr, _ingr) + # self.cursor.execute(query_ingr) + # self.conn.commit() - if _avoid_ingr != None: - query_avoid_ingr = noingredient_query(table_ingr, '', table_avoid_ingr, _avoid_ingr) - self.cursor.execute(query_avoid_ingr) - self.conn.commit() + # if _avoid_ingr != None: + # query_avoid_ingr = noingredient_query(table_ingr, '', table_avoid_ingr, _avoid_ingr) + # self.cursor.execute(query_avoid_ingr) + # self.conn.commit() - if _ethn != None: - query_ethn = cuisine_query(table_ingr, table_ethn, _ethn) - self.cursor.execute(query_ethn) - self.conn.commit() + # if _ethn != None: + # query_ethn = cuisine_query(table_ingr, table_ethn, _ethn) + # self.cursor.execute(query_ethn) + # self.conn.commit() - if _diet != None: - query_diet = diet_query(table_ethn, table_diet, _diet) - self.cursor.execute(query_diet) - self.conn.commit() + # if _diet != None: + # query_diet = diet_query(table_ethn, table_diet, _diet) + # self.cursor.execute(query_diet) + # self.conn.commit() - rows += self.cursor.fetchall() + #rows += self.cursor.fetchall() #AVEC METHODE 2 - # query = request(_name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr) + # query = request(_name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, _sort_alph) #self.cursor.execute(query) #self.conn.commit() #rows = self.cursor.fecthall() -- GitLab From 463901f518140fa25caa933daeaeec96039559e2 Mon Sep 17 00:00:00 2001 From: Nawel HEBRI <nawel.hebri@edu.univ-paris13.fr> Date: Sun, 29 Dec 2024 18:15:49 +0100 Subject: [PATCH 17/21] "modif" --- foodApp.py | 1 + 1 file changed, 1 insertion(+) diff --git a/foodApp.py b/foodApp.py index c84a71a..2a9c4e2 100644 --- a/foodApp.py +++ b/foodApp.py @@ -395,6 +395,7 @@ class MainWindow(QtWidgets.QMainWindow): _time = str(self.time_box.currentText()) _avoid_ingr = str(self.av_box.currentText()) _sort_time = str(self.sort_button.currentText()) + _sort_alph = str(self.sort) rows = [] -- GitLab From 8171d35ae34a044df6ad350957c75ecd233685f0 Mon Sep 17 00:00:00 2001 From: Nawel HEBRI <nawel.hebri@edu.univ-paris13.fr> Date: Sun, 29 Dec 2024 19:38:40 +0100 Subject: [PATCH 18/21] "mdif again" --- foodApp.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/foodApp.py b/foodApp.py index 2a9c4e2..0f0c47a 100644 --- a/foodApp.py +++ b/foodApp.py @@ -3,6 +3,7 @@ import psycopg2 from PyQt5 import (QtGui, QtCore, QtWidgets, QtGui) from PyQt5.QtWidgets import(QComboBox, QApplication, QCompleter, QGridLayout, QRadioButton, QButtonGroup) from PyQt5.QtCore import Qt +from requete.py import * # /!\ IMPORTANT /!\ #Créer la table user au préable comme suit : @@ -441,10 +442,10 @@ class MainWindow(QtWidgets.QMainWindow): #rows += self.cursor.fetchall() #AVEC METHODE 2 - # query = request(_name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, _sort_alph) - #self.cursor.execute(query) - #self.conn.commit() - #rows = self.cursor.fecthall() + query = request(_name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, _sort_alph) + self.cursor.execute(query) + self.conn.commit() + rows = self.cursor.fecthall() if _hops>= 1 : self.cursor.execute(""f""" SELECT """) -- GitLab From 8116ca8751c7f1913b052df14b06d5fc87916b42 Mon Sep 17 00:00:00 2001 From: Nawel HEBRI <nawel.hebri@edu.univ-paris13.fr> Date: Sun, 29 Dec 2024 20:36:32 +0100 Subject: [PATCH 19/21] update requete.py --- requete.py | 128 +++++++++++++++++++++++++++++------------------------ 1 file changed, 71 insertions(+), 57 deletions(-) diff --git a/requete.py b/requete.py index 3a6669d..2658bf7 100644 --- a/requete.py +++ b/requete.py @@ -1,3 +1,34 @@ +import re + +def verification(tab, _name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, _sort_alph): + tmp = None + if tab == "name": + tmp = _name + elif tab == "ingredients": + tmp = _ingr + elif tab == "diet": + tmp = _diet + elif tab == "course": + tmp = _course + elif tab == "cuisine": + tmp = _ethn + elif tab == "total_time": + #transform list to string to minutes (join concatenates) + time = int(''.join(re.findall(r'\d', _time))) + if time != 30: + tmp = time * 60 + else: + tmp = time + + return tmp + +def find_list(tab, val_to_find): + i = 0 + for i in range(len(tab)): + if tab[i] == val_to_find: + return 0 + return -1 + def request(_name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, _sort_alph): request1 = "SELECT distinct name, image FROM ethnic WHERE " request2 = "SELECT distinct name, image FROM general WHERE " @@ -8,36 +39,36 @@ def request(_name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, test = 0 if _name != None: - tab += "name" + tab.append("name") if _ingr != None: - tab += "ingredients" + tab.append("ingredients") if _diet != None: - tab += "diet" + tab.append("diet") if _course != None: - tab += "course" + tab.append("course") if _ethn != None: - tab += "cuisine" + tab.append("cuisine") if _time != None: - tab += "total_time" + tab.append("total_time") if _avoid_ingr != None: - tab += "ingredients" + tab.append("ingredients") test = len(tab) if _sort_alph != None: - tab_order += "sort_alph" + tab_order.append("sort_alph") if _sort_time != None: - tab_order += "sort_time" + tab_order.append("sort_time") i = 0 - if tab.find("diet") != -1 | tab.find("cuisine") != -1: + if find_list(tab, "diet") != -1 or find_list(tab, "cuisine") != -1: for i in range(len(tab) - 1): tmp = verification(tab[i], _name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, _sort_alph) - if tab[i] == "ingredients" & i != (test - 1): + if tab[i] == "ingredients" and i != (test - 1): #with ingredient case request1 += tab[i] + " LIKE '%{tmp}%' AND " - elif tab[i] == "ingredients" & i == (test - 1): + elif tab[i] == "ingredients" and i == (test - 1): #avoid ingredient case request1 += tab[i] + " NOT LIKE '%{tmp}%' AND " else: @@ -45,43 +76,43 @@ def request(_name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, tmp = verification(tab[len(tab) - 1], _name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, _sort_alph) - if tab[len(tab) - 1] == "ingredients" & i != (test - 1): + if tab[len(tab) - 1] == "ingredients" and i != (test - 1): #with ingredient case request1 += tab[len(tab) - 1] + " LIKE '%{tmp}%'" - elif tab[len(tab) - 1] == "ingredients" & i == (test - 1): + elif tab[len(tab) - 1] == "ingredients" and i == (test - 1): #avoid ingredient case request1 += tab[len(tab) - 1] + " NOT LIKE '%{tmp}%'" else: - request1 += tab[len(tab)] + " = '{tmp}'" + request1 += tab[len(tab) - 1] + " = '{tmp}'" request1 += " ORDER BY " for i in range(len(tab_order)): if tab_order[i] == "sort_alph": - if _sort_alph == "ascendant": # A MODIFIER - request1 += "name ASC" - elif _sort_alph == "descendant": # A MODIFIER - request1 += "name DESC" + if _sort_alph == "ascendant":# A MODIFIER + request1 += "name ASC" + elif _sort_alph == "descendant":# A MODIFIER + request1 += "name DESC" - if i < len(tab_order) - 1: - request1 += ", " + if i < len(tab_order) - 1: + request1 += ", " if tab_order[i] == "sort_time": if _sort_time == "ascendant": # A MODIFIER - request1 += "total_time ASC" - elif _sort_time == "descendant": # A MODIFIER - request1 += "total_time DESC" + request1 += "total_time ASC" + elif _sort_time == "descendant": # A MODIFIER + request1 += "total_time DESC" request = request1 - + else: for i in range(len(tab) - 1): tmp = verification(tab[i], _name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, _sort_alph) - if tab[i] == "ingredients" & i != (test - 1): + if tab[i] == "ingredients" and i != (test - 1): #with ingredient case request1 += tab[i] + " LIKE '%{tmp}%' AND " request2 += tab[i] + " LIKE '%{tmp}%' AND " - elif tab[i] == "ingredients" & i == (test - 1): + elif tab[i] == "ingredients" and i == (test - 1): #avoid ingredient case request1 += tab[i] + " NOT LIKE '%{tmp}%' AND " request1 += tab[i] + " NOT LIKE '%{tmp}%' AND " @@ -91,11 +122,11 @@ def request(_name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, tmp = verification(tab[len(tab) - 1], _name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, _sort_alph) - if tab[i] == "ingredients" & i != (test - 1): + if tab[i] == "ingredients" and i != (test - 1): #with ingredient case request1 += tab[len(tab) - 1] + " LIKE '%{tmp}%'" request2 += tab[len(tab) - 1] + " LIKE '%{tmp}%'" - elif tab[i] == "ingredients" & i == (test - 1): + elif tab[i] == "ingredients" and i == (test - 1): #avoid ingredient case request1 += tab[len(tab) - 1] + " NOT LIKE '%{tmp}%'" request1 += tab[len(tab) - 1] + " NOT LIKE '%{tmp}%'" @@ -111,39 +142,22 @@ def request(_name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, for i in range(len(tab_order)): if tab_order[i] == "sort_alph": if _sort_alph == "ascendant": # A MODIFIER - request += "name ASC" - elif _sort_alph == "descendant": #A MODIFIER - request += "name DESC" + request += "name ASC" + elif _sort_alph == "descendant": #A MODIFIER + request += "name DESC" - if i < len(tab_order) - 1: - request += ", " + if i < len(tab_order) - 1: + request += ", " if tab_order[i] == "sort_time": if _sort_time == "ascendant": #A MODIFIER - request += "total_time ASC" - elif _sort_time == "descendant": #A MODIFIER - request += "total_time DESC" + request += "total_time ASC" + elif _sort_time == "descendant": #A MODIFIER + request += "total_time DESC" return request + ";" - def verification(tab, _name, _ingr, _diet, _course, _ethn, _time, _avoid_ingr, _sort_time, _sort_alph): - if tab == "name": - tmp = _name - elif tab == "ingredients": - tmp = _ingr - elif tab == "diet": - tmp = _diet - elif tab == "course": - tmp = _course - elif tab == "cuisine": - tmp = _cuisine - else tab == "total_time": - #transform list to string to minutes (join concatenates) - time = int(''.join(re.findall(r'\d', _time))) - if time != 30: - tmp = time * 60 - else: - tmp = time - return tmp - + +query = request(None, "zucchini", None, None, None, "45", None, None, "ascendant") +print(query) -- GitLab From a1faf331b58f7edcd441e98364af906308154fb5 Mon Sep 17 00:00:00 2001 From: Nawel HEBRI <nawel.hebri@edu.univ-paris13.fr> Date: Sun, 29 Dec 2024 00:25:23 +0100 Subject: [PATCH 20/21] Modification de requete.py et de foodapp.py --- foodApp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/foodApp.py b/foodApp.py index 0f0c47a..abdc1df 100644 --- a/foodApp.py +++ b/foodApp.py @@ -348,7 +348,7 @@ class MainWindow(QtWidgets.QMainWindow): _label_avoid = QtWidgets.QLabel('Avoid ', self) _label_avoid.setFixedSize(50,20) self.av_box = QtWidgets.QComboBox() - self.av_box.addItems(rows) + self.av_box.addItems( ['Test1', 'Test2'] ) self.av_box.setCurrentIndex( -1 ) control_layout.addWidget(_label_avoid, 3, 0) control_layout.addWidget(self.av_box, 3, 1) -- GitLab From 9d8d84054bc1b53e401ccb798a6884dfbf3d739e Mon Sep 17 00:00:00 2001 From: Nawel HEBRI <nawel.hebri@edu.univ-paris13.fr> Date: Sun, 29 Dec 2024 00:35:33 +0100 Subject: [PATCH 21/21] Update requete et foodapp files --- foodApp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/foodApp.py b/foodApp.py index abdc1df..0f0c47a 100644 --- a/foodApp.py +++ b/foodApp.py @@ -348,7 +348,7 @@ class MainWindow(QtWidgets.QMainWindow): _label_avoid = QtWidgets.QLabel('Avoid ', self) _label_avoid.setFixedSize(50,20) self.av_box = QtWidgets.QComboBox() - self.av_box.addItems( ['Test1', 'Test2'] ) + self.av_box.addItems(rows) self.av_box.setCurrentIndex( -1 ) control_layout.addWidget(_label_avoid, 3, 0) control_layout.addWidget(self.av_box, 3, 1) -- GitLab