diff options
Diffstat (limited to 'src/gui/windowRecherche.py')
| -rw-r--r-- | src/gui/windowRecherche.py | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/gui/windowRecherche.py b/src/gui/windowRecherche.py new file mode 100644 index 0000000..c86bcc9 --- /dev/null +++ b/src/gui/windowRecherche.py @@ -0,0 +1,63 @@ + +from PyQt5.QtWidgets import ( + QDialog, QVBoxLayout, QHBoxLayout, + QLabel, QPushButton, QMessageBox +) +from src.database import dbsearch +# https://docs.python.org/3/faq/programming.html#why-do-lambdas-defined-in-a-loop-with-different-values-all-return-the-same-result +# https://stackoverflow.com/questions/53751106/create-lambda-functions-in-a-loop-for-pyqt5-signals?noredirect=1 + + +def more_infos(mainWindow, proId): + search: object = dbsearch.DbSearch(mainWindow) + resRecherche: list = search.get_user_info_by_userid(proId)[0][1:] + label: list = [ + "Nom", + "Prénom", + "Diplôme", + "Capacités", + "Description", + "Téléphone", + "Adresse", + "Code postale", + "Ville", + ] + text: list = [] + print(resRecherche) + for i in range(len(resRecherche)): + text.append(f"{label[i]}: {resRecherche[i]}") + + QMessageBox.information( + mainWindow, + "Informations du pro", + "\n".join(text) + ) + +def main(mainWindow: object, results: list) -> None: + dial = QDialog(parent = mainWindow) + dial.setWindowTitle("Recherche") + layoutsResult: list = [] + for i in results: + layoutLine = QHBoxLayout() + color = results.index(i) % 2 + if color: + colored = QLabel(i["text"]) + colored.setStyleSheet("background-color: rgb(230,200,200); border-radius: 3px") + layoutLine.addWidget(colored) + else: + layoutLine.addWidget(QLabel(i["text"])) + btnInfos = QPushButton("Infos") + btnInfos.clicked.connect( + lambda checked, proId = i['id']: + more_infos(mainWindow, proId) + ) + layoutLine.addStretch() + layoutLine.addWidget(btnInfos) + layoutsResult.append(layoutLine) + + layoutMain = QVBoxLayout() + for layout in layoutsResult: + layoutMain.addLayout(layout) + + dial.setLayout(layoutMain) + dial.show() |
