The Treeview widget is added to our application, but we need a way to fill it with data.
We'll create a method called populate_recordlist() by executing the following code:
def populate_recordlist(self):
The logic is simple enough: just get all the rows from the model and send them to the record list's populate() method.
We could write it as simply as this:
rows = self.data_model.get_all_records() self.recordlist.populate(rows)
Remember, though, that in the event of a problem with the file, get_all_records() will raise an Exception; we need to catch that exception and let the user know things are wrong.
Update the code with the try and except blocks as follows:
try: rows = self.data_model.get_all_records() except ...