May 2019
Intermediate to advanced
542 pages
13h 37m
English
The next callback is populate_form(), which will be called when an event is selected and populate the event details form. It begins like this:
def populate_form(self): self.clear_form() date = self.calendar.selectedDate() event_number = self.event_list.currentRow() if event_number == -1: return
Here, we start by clearing the form, then retrieving the selected date from the calendar, and the selected event from the event list. When no event is selected, QListWidget.currentRow() returns a value of -1; in that case, we'll just return, leaving the form blank.
The remainder of the method looks like this:
event_data = self.events.get(date)[event_number] self.event_category.setCurrentText(event_data['category']) if ...
Read now
Unlock full access