(self)
| 10 | |
| 11 | class Application(ctk.CTk): |
| 12 | def __init__(self): |
| 13 | super().__init__() |
| 14 | |
| 15 | # configure window |
| 16 | self.title("Finance Tracker") |
| 17 | self.geometry(f"{800}x{500}") |
| 18 | |
| 19 | # configure grid layout |
| 20 | self.grid_columnconfigure(1, weight=5) |
| 21 | self.grid_rowconfigure(0, weight=5) |
| 22 | |
| 23 | self.income = 0 |
| 24 | self.expense = 0 |
| 25 | self.income_transactions = [] |
| 26 | self.expense_transactions = [] |
| 27 | |
| 28 | # create main frame |
| 29 | self.main_frame = ctk.CTkFrame(self, corner_radius=0) |
| 30 | self.main_frame.grid(row=0, column=1, sticky="nsew", padx=20, pady=20) |
| 31 | |
| 32 | # create sidebar frame with widgets |
| 33 | self.sidebar_frame = ctk.CTkFrame(self, width=250, corner_radius=0) |
| 34 | self.sidebar_frame.grid(row=0, column=0, sticky="nsew", padx=20, pady=20) |
| 35 | |
| 36 | self.logo_label = ctk.CTkLabel(self.sidebar_frame, text="Finance Tracker", |
| 37 | font=ctk.CTkFont(size=30, weight="bold")) |
| 38 | self.logo_label.grid(row=0, column=0, padx=20, pady=(20, 10)) |
| 39 | |
| 40 | # Adding navigation buttons |
| 41 | self.income_button = ctk.CTkButton(self.sidebar_frame, text="Income", command=self.income_button_event) |
| 42 | self.income_button.grid(row=1, column=0, padx=20, pady=20) |
| 43 | self.expenses_button = ctk.CTkButton(self.sidebar_frame, text="Expenses", command=self.expenses_button_event) |
| 44 | self.expenses_button.grid(row=2, column=0, padx=20, pady=20) |
| 45 | self.balance_button = ctk.CTkButton(self.sidebar_frame, text="Balance", command=self.balance_button_event) |
| 46 | self.balance_button.grid(row=3, column=0, padx=20, pady=20) |
| 47 | |
| 48 | # Create Entry fields(User can type the text) |
| 49 | self.income_frame, self.income_tree = self.create_transaction_frame("Income", self.add_income, row=1, transactions=self.income_transactions) |
| 50 | self.expense_frame, self.expense_tree = self.create_transaction_frame("Expense", self.add_expense, row=2, transactions=self.expense_transactions) |
| 51 | self.balance_frame = self.create_balance_frame(row=3) |
| 52 | |
| 53 | self.hide_frames() |
| 54 | self.income_frame.grid() |
| 55 | |
| 56 | # Plot |
| 57 | self.fig = Figure(figsize = (4, 4), dpi = 100) |
| 58 | self.canvas = FigureCanvasTkAgg(self.fig, master = self.balance_frame) |
| 59 | self.canvas.get_tk_widget().grid(row=1, column=0) |
| 60 | |
| 61 | def create_transaction_frame(self, title, button_command, row, transactions): |
| 62 | frame = ctk.CTkFrame(self.main_frame) |
nothing calls this directly
no test coverage detected