Handle categories

This commit is contained in:
Marcel Kapfer 2020-04-30 21:34:58 +02:00
parent 0dd70e8461
commit 07ee4e3737
Signed by: mmk2410
GPG Key ID: CADE6F0C09F21B09
1 changed files with 12 additions and 0 deletions

12
init.py
View File

@ -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.