I can’t test it since you didn’t provide a working example, but the first thing I notice is that you increment trow after you add the row, so the last row is trow – 1. Since you’ll need to decrement it anyway just do that before you try to delete.
def delete_row():
trow -= 1
l=list(table.grid_slaves(row=trow))
for w in l:
w.grid_forget()
Or better yet, forget using your own variable and use table.grid_size()
to find the row to add or delete.
Edit: also you seem to be passing a string, not a function, to the button. Change that line to:
deleteButton = Button(text="delete row", command=delete_row)
2
solved Tkinter – Deleting rows from a grid dynamically