Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit 6f83228

Browse files
committed
chore: polished code
1 parent 4672d90 commit 6f83228

5 files changed

Lines changed: 72 additions & 59 deletions

File tree

projects/Expense-Tracker/app.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import tkinter as tk
2-
from tkinter import ttk
31
from tkinter import messagebox
42
import customtkinter as ctk
53

@@ -361,3 +359,9 @@ def on_row_selected(self, e):
361359
category=values[4],
362360
subcategory=values[5]
363361
)
362+
363+
364+
if __name__ == '__main__':
365+
DB_PATH = str(Path(__file__).resolve().parent / 'items.json')
366+
app = App(DB_PATH)
367+
app.mainloop()

projects/Expense-Tracker/expense_income_stats.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from item import ItemsDB
33
import pandas as pd
44
import statistics
5-
from reportlab.pdfgen import canvas
65

76

87
class ExpenseIncomeStats:

projects/Expense-Tracker/gui_widgets.py

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import tkinter as tk
22
from tkinter import ttk
3-
import customtkinter as ctk
4-
import os
53
from pathlib import Path
64

7-
from item import ItemsDB, Item, Category
5+
from item import ItemsDB
86
from expense_income_stats import ExpenseIncomeStats
97

108

@@ -29,53 +27,8 @@ def __init__(self, parent, items_db: ItemsDB, *args, **kwargs):
2927
self._parent = parent
3028
self._items_db = items_db
3129

32-
# For Testing
33-
self._test_add_items_to_db()
3430
self.load_items()
3531

36-
def _test_add_items_to_db(self):
37-
items = \
38-
[Item.create_income_item('Bitcoin',
39-
500,
40-
"Income from Bitcoin",
41-
'2023-06-25',
42-
Category('Personal Finance', 'Investing')
43-
),
44-
Item.create_income_item('Youtube Ads',
45-
5,
46-
"Income from Youtube Ads",
47-
'2024-1-10',
48-
Category('Youtube')
49-
),
50-
Item.create_income_item('Gift',
51-
30,
52-
"Gift from Relatives",
53-
'2024-03-04'
54-
),
55-
Item.create_expense_item('Pizza',
56-
50,
57-
"Pizza from Pizza Hut",
58-
'2023-04-20',
59-
Category('Food', 'Junk')
60-
),
61-
Item.create_expense_item('Bus',
62-
20,
63-
"Travel Expenses by Bus",
64-
'2024-02-05',
65-
Category('Transportation')
66-
),
67-
Item.create_expense_item('Bitcoin',
68-
-300,
69-
"Loss on Bitcoin Gambling.",
70-
'2024-04-20'
71-
),
72-
]
73-
self._items_db.insert_items(items)
74-
75-
def clear_test(self):
76-
if os.path.exists(self._items_db.db_path):
77-
os.remove(self._items_db.db_path)
78-
7932
def clear_items(self):
8033
# Clearing all the rows in Items Table (Not Deleting!)
8134
self.delete(*self.get_children())

projects/Expense-Tracker/main.py

Lines changed: 0 additions & 8 deletions
This file was deleted.

projects/Expense-Tracker/sample.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
from pathlib import Path
2+
import os
3+
4+
from app import App
5+
from item import ItemsDB, Item, Category
6+
7+
DB_PATH = str(Path(__file__).resolve().parent / 'items.json')
8+
9+
10+
def mock_add_items():
11+
items = \
12+
[Item.create_income_item('Bitcoin',
13+
500,
14+
"Income from Bitcoin",
15+
'2023-06-25',
16+
Category('Personal Finance', 'Investing')
17+
),
18+
Item.create_income_item('Youtube Ads',
19+
5,
20+
"Income from Youtube Ads",
21+
'2024-1-10',
22+
Category('Youtube')
23+
),
24+
Item.create_income_item('Gift',
25+
30,
26+
"Gift from Relatives",
27+
'2024-03-04'
28+
),
29+
Item.create_expense_item('Pizza',
30+
50,
31+
"Pizza from Pizza Hut",
32+
'2023-04-20',
33+
Category('Food', 'Junk')
34+
),
35+
Item.create_expense_item('Bus',
36+
20,
37+
"Travel Expenses by Bus",
38+
'2024-02-05',
39+
Category('Transportation')
40+
),
41+
Item.create_expense_item('Bitcoin',
42+
-300,
43+
"Loss on Bitcoin Gambling.",
44+
'2024-04-20'
45+
),
46+
]
47+
ItemsDB(DB_PATH).insert_items(items)
48+
49+
50+
def mock_clear_test():
51+
if os.path.exists(DB_PATH):
52+
os.remove(DB_PATH)
53+
54+
if os.path.exists(str(Path(__file__).resolve().parent / 'report.xlsx')):
55+
os.remove(str(Path(__file__).resolve().parent / 'report.xlsx'))
56+
57+
if os.path.exists(str(Path(__file__).resolve().parent / 'report.pdf')):
58+
os.remove(str(Path(__file__).resolve().parent / 'report.pdf'))
59+
60+
61+
if __name__ == '__main__':
62+
mock_add_items()
63+
app = App(DB_PATH)
64+
app.mainloop()
65+
mock_clear_test()

0 commit comments

Comments
 (0)