diff --git a/src/main.py b/src/main.py index 25791df..b4cfb91 100644 --- a/src/main.py +++ b/src/main.py @@ -25,41 +25,41 @@ class MedTrackerApp: input_frame = ttk.LabelFrame(main_frame, text="New Entry") input_frame.grid(row=0, column=0, padx=10, pady=10, sticky="ew") - ttk.Label(input_frame, text="Depression (1-10):").grid( + ttk.Label(input_frame, text="Depression (0-10):").grid( row=0, column=0, sticky="w", padx=5, pady=2 ) self.depression_var = tk.IntVar() ttk.Scale( input_frame, - from_=1, + from_=0, to=10, orient=tk.HORIZONTAL, variable=self.depression_var, ).grid(row=0, column=1, sticky="ew") - ttk.Label(input_frame, text="Anxiety (1-10):").grid( + ttk.Label(input_frame, text="Anxiety (0-10):").grid( row=1, column=0, sticky="w", padx=5, pady=2 ) self.anxiety_var = tk.IntVar() ttk.Scale( - input_frame, from_=1, to=10, orient=tk.HORIZONTAL, variable=self.anxiety_var + input_frame, from_=0, to=10, orient=tk.HORIZONTAL, variable=self.anxiety_var ).grid(row=1, column=1, sticky="ew") - ttk.Label(input_frame, text="Sleep Quality (1-10):").grid( + ttk.Label(input_frame, text="Sleep Quality (0-10):").grid( row=2, column=0, sticky="w", padx=5, pady=2 ) self.sleep_var = tk.IntVar() ttk.Scale( - input_frame, from_=1, to=10, orient=tk.HORIZONTAL, variable=self.sleep_var + input_frame, from_=0, to=10, orient=tk.HORIZONTAL, variable=self.sleep_var ).grid(row=2, column=1, sticky="ew") - ttk.Label(input_frame, text="Appetite (1-10):").grid( + ttk.Label(input_frame, text="Appetite (0-10):").grid( row=3, column=0, sticky="w", padx=5, pady=2 ) self.appetite_var = tk.IntVar() ttk.Scale( input_frame, - from_=1, + from_=0, to=10, orient=tk.HORIZONTAL, variable=self.appetite_var, @@ -121,14 +121,14 @@ class MedTrackerApp: self.load_data() - def on_double_click(self, event): + def on_double_click(self, event) -> None: """Handle double-click event to edit an entry.""" if len(self.tree.get_children()) > 0: item_id = self.tree.selection()[0] item_values = self.tree.item(item_id, "values") self.create_edit_window(item_id, item_values) - def create_edit_window(self, item_id, values): + def create_edit_window(self, item_id, values) -> None: """Create a new Toplevel window for editing an entry.""" edit_win = tk.Toplevel(self.root) edit_win.title("Edit Entry") @@ -200,8 +200,12 @@ class MedTrackerApp: cancel_btn = ttk.Button(edit_win, text="Cancel", command=edit_win.destroy) cancel_btn.grid(row=6, column=1, padx=5, pady=10) - def save_edit(self, edit_win, timestamp, dep, anx, slp, app, note): - """Save the edited data to the CSV file.""" + def save_edit( + self, edit_win, timestamp, dep: int, anx: int, slp: int, app: int, note: str + ) -> None: + """ + Save the edited data to the CSV file. + """ df = pd.read_csv(self.filename) # Find the row to update using the timestamp as a unique identifier df.loc[ @@ -215,12 +219,12 @@ class MedTrackerApp: messagebox.showinfo("Success", "Entry updated successfully!") self.load_data() - def on_closing(self): + def on_closing(self) -> None: if messagebox.askokcancel("Quit", "Do you want to quit the application?"): plt.close(self.fig) self.root.destroy() - def initialize_csv(self): + def initialize_csv(self) -> None: if not os.path.exists(self.filename): with open(self.filename, mode="w", newline="") as file: writer = csv.writer(file) @@ -228,7 +232,7 @@ class MedTrackerApp: ["timestamp", "depression", "anxiety", "sleep", "appetite", "note"] ) - def add_entry(self): + def add_entry(self) -> None: timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S") with open(self.filename, mode="a", newline="") as file: writer = csv.writer(file) @@ -247,14 +251,14 @@ class MedTrackerApp: self.clear_entries() self.load_data() - def clear_entries(self): + def clear_entries(self) -> None: self.depression_var.set(0) self.anxiety_var.set(0) self.sleep_var.set(0) self.appetite_var.set(0) self.note_var.set("") - def load_data(self): + def load_data(self) -> None: for i in self.tree.get_children(): self.tree.delete(i) @@ -269,7 +273,7 @@ class MedTrackerApp: except pd.errors.EmptyDataError: self.update_graph(pd.DataFrame()) - def update_graph(self, df): + def update_graph(self, df: pd.DataFrame) -> None: self.ax.clear() if not df.empty: df["timestamp"] = pd.to_datetime(df["timestamp"])