-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrollers.py
More file actions
38 lines (33 loc) · 1.47 KB
/
Copy pathcontrollers.py
File metadata and controls
38 lines (33 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from kivy.uix.screenmanager import Screen
from models import add_expense, set_budget, get_expense_reports, get_expenses
class AddExpenseScreen(Screen):
def submit_expense(self, date, amount, category, description):
try:
# Convert amount to float and attempt to add expense to database
amount = float(amount)
add_expense(date, amount, category, description)
print(f"Expense added: {date}, {amount}, {category}, {description}")
except ValueError:
print("Error: Invalid amount. Please enter a valid number.")
except Exception as e:
print(f"Error adding expense: {e}")
class ViewExpensesScreen(Screen):
def on_enter(self):
expenses = get_expenses()
for expense in expenses:
print(expense) # Ideally, update a list widget or similar display method
class SetBudgetScreen(Screen):
def submit_budget(self, category, amount):
try:
amount = float(amount)
set_budget(category, amount)
print(f"Budget set: {category} with amount {amount}")
except ValueError:
print("Error: Invalid budget amount. Please enter a valid number.")
except Exception as e:
print(f"Error setting budget: {e}")
class ViewReportsScreen(Screen):
def on_enter(self):
reports = get_expense_reports()
for report in reports:
print(report) # Ideally, this would update a graphical report view