Add verification of number of items in the table to prevent editing an empty object with no index
This commit is contained in:
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user