May 2019
Intermediate to advanced
542 pages
13h 37m
English
The delete_event method will be called whenever the Delete button is clicked, and it looks like this:
def delete_event(self): date = self.calendar.selectedDate() row = self.event_list.currentRow() del(self.events[date][row]) self.event_list.setCurrentRow(-1) self.clear_form() self.populate_list()
Once again, we retrieve the current date and currently selected row and use them to locate the event in self.events that we want to delete. After deleting the item from the list, we set the list widget to no selection by setting currentRow to -1. Then, we clear the form and populate the list widget.
Note that we don't bother checking to see whether the currently selected row is -1, because we plan to disable the delete ...
Read now
Unlock full access