diff --git a/src/main.py b/src/main.py index 955ee72..ad38aaf 100644 --- a/src/main.py +++ b/src/main.py @@ -19,7 +19,13 @@ class MedTrackerApp: self.root.title("Thechart - medication tracker") self.root.protocol("WM_DELETE_WINDOW", self.on_closing) # self.root.iconbitmap("app_icon.ico") - # self.root.geometry("800x600") + # screen_width = self.root.winfo_screenwidth() + # screen_height = self.root.winfo_screenheight() + # self.root.geometry(f"{screen_width}x{screen_height}") + # self.root.configure(background='gold') + # self.root.lift() + + self.filename = "thechart_data.csv" if len(sys.argv) > 1: script_name = sys.argv[0] @@ -33,7 +39,6 @@ class MedTrackerApp: self.filename = first_argument logger.info(f"Using data file: {first_argument}") else: - self.filename = "thechart_data.csv" logger.warning( f"Data file {first_argument} does not exist." f" Using default file: {self.filename}" @@ -235,7 +240,7 @@ class MedTrackerApp: def create_edit_window(self, item_id: str, values: tuple) -> None: """Create a new Toplevel window for editing an entry.""" - edit_win = tk.Toplevel(self.root) + edit_win = tk.Toplevel(master=self.root) edit_win.title("Edit Entry") # Unpack values @@ -398,12 +403,14 @@ class MedTrackerApp: df.to_csv(self.filename, index=False) edit_win.destroy() - messagebox.showinfo("Success", "Entry updated successfully!") + messagebox.showinfo("Success", "Entry updated successfully!", parent=self.root) self.clear_entries() self.load_data() def on_closing(self) -> None: - if messagebox.askokcancel("Quit", "Do you want to quit the application?"): + if messagebox.askokcancel( + "Quit", "Do you want to quit the application?", parent=self.root + ): plt.close(self.fig) self.root.destroy() @@ -444,7 +451,7 @@ class MedTrackerApp: ] ) - messagebox.showinfo("Success", "Entry added successfully!") + messagebox.showinfo("Success", "Entry added successfully!", parent=self.root) self.clear_entries() self.load_data() @@ -453,7 +460,9 @@ class MedTrackerApp: Delete the selected entry from the CSV file. """ if messagebox.askyesno( - "Delete Entry", "Are you sure you want to delete this entry?" + "Delete Entry", + "Are you sure you want to delete this entry?", + parent=edit_win, ): df = pd.read_csv(self.filename) # Get the date of the entry to delete @@ -464,7 +473,9 @@ class MedTrackerApp: df.to_csv(self.filename, index=False) edit_win.destroy() - messagebox.showinfo("Success", "Entry deleted successfully!") + messagebox.showinfo( + "Success", "Entry deleted successfully!", parent=edit_win + ) self.load_data() def clear_entries(self) -> None: