From a31873e25dfd7f310763bea85ad83fd4d50812f4 Mon Sep 17 00:00:00 2001 From: Valtteri Kantanen Date: Tue, 3 May 2022 21:54:42 +0300 Subject: [PATCH] Ask confirmation from the user when deleting a category --- src/ui/budget_view.py | 2 +- src/ui/category_view.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ui/budget_view.py b/src/ui/budget_view.py index 419805a..f6c8742 100644 --- a/src/ui/budget_view.py +++ b/src/ui/budget_view.py @@ -60,7 +60,7 @@ def select_item(a): transaction_id = transactions[i][0] datetime_object = datetime.strptime(transactions[i][1], "%Y-%m-%d") date = datetime.strftime(datetime_object, "%-d.%-m.%Y") - amount = f"{('%.2f' % (transactions[i][2] / 100)).replace('.', ',')} €" + amount = f"{('%.2f' % (transactions[i][2] / 100)).replace('.', ',').replace('-', '−')} €" category = transactions[i][3] description = transactions[i][4] transaction_list.insert(parent="", index="end", iid=i, text="", values=(transaction_id, date, amount, category, description)) diff --git a/src/ui/category_view.py b/src/ui/category_view.py index 86d2f39..673a6e4 100644 --- a/src/ui/category_view.py +++ b/src/ui/category_view.py @@ -1,5 +1,3 @@ -from datetime import datetime - import tkinter as tk from tkinter import ttk, messagebox @@ -54,8 +52,10 @@ def select_item(a): def delete(): selected_item = category_list.selection()[0] if category_list.selection() else None if selected_item: - budget_service.delete_category(self._selected_category_id) - category_list.delete(selected_item) + answer = messagebox.askyesno(message="Haluatko varmasti poistaa kategorian?", icon="warning") + if answer: + budget_service.delete_category(self._selected_category_id) + category_list.delete(selected_item) else: messagebox.showerror(message="Valitse kategoria!")