Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Expense Tracker/expense.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""
DebEx - Expense Tracker GUI
Description: Track, filter, delete, and export expenses.
Dependencies: tkinter, tkcalendar, sqlite3.
"""
import datetime
import sqlite3
from tkcalendar import DateEntry
Expand Down Expand Up @@ -36,7 +41,7 @@ def remove_expense():
surety = tb.askyesno('Are you sure?', f'Are you sure that you want to delete the record of {values_selected[2]}')

if surety:
connector.execute('DELETE FROM ExpenseTracker WHERE ID=%d' % values_selected[0])
connector.execute('DELETE FROM ExpenseTracker WHERE ID=?', (values_selected[0],))
connector.commit()

list_all_expenses()
Expand Down Expand Up @@ -289,6 +294,11 @@ def export_to_csv():
table.place(relx=0, y=0, relheight=1, relwidth=1)

list_all_expenses()

# Show total expenses
total_amount = sum([row[4] for row in connector.execute('SELECT * FROM ExpenseTracker')])
Label(root, text=f"Total Expenses: {total_amount}", font=("Georgia", 14)).place(x=950, y=10)

# Finalizing the GUI window
root.update()
root.mainloop()