Add verification of number of items in the table to prevent editing an empty object with no index

This commit is contained in:
William Valentin
2025-07-15 14:36:17 -07:00
parent dcb6470797
commit 96fa2551f6

View File

@@ -123,9 +123,10 @@ class MedTrackerApp:
def on_double_click(self, event):
"""Handle double-click event to edit an entry."""
item_id = self.tree.selection()[0]
item_values = self.tree.item(item_id, "values")
self.create_edit_window(item_id, item_values)
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):
"""Create a new Toplevel window for editing an entry."""