From 07ee4e373724c6cddfbb0cc0463bee1e570b3c82 Mon Sep 17 00:00:00 2001 From: Marcel Kapfer Date: Thu, 30 Apr 2020 21:34:58 +0200 Subject: [PATCH] Handle categories --- init.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/init.py b/init.py index d8c9f63..34eabe7 100644 --- a/init.py +++ b/init.py @@ -25,6 +25,11 @@ class MainWindow(QMainWindow, Ui_MainWindow): # Conncect recipe name typing self.e_recipe_name.textChanged.connect(self.updateTitle) + # Handle category buttons + self.b_category_add.clicked.connect(self.category_add) + self.e_category.returnPressed.connect(self.category_add) + self.b_category_remove.clicked.connect(self.category_remove) + self.show() def updateTitle(self): @@ -37,6 +42,13 @@ class MainWindow(QMainWindow, Ui_MainWindow): else: self.setWindowTitle("WikiCookBook") + def category_add(self): + if self.e_category.text(): + self.v_categories.addItem(f"Kategorie{self.e_category.text()}") + + def category_remove(self): + self.v_categories.takeItem(self.v_categories.currentRow()) + def close(self): """ Close the application. A warning is shown before.