May 2018
Beginner to intermediate
452 pages
11h 26m
English
Now that we have our Treeview widget, we'll create a populate() method to populate it with data:
def populate(self, rows):
"""Clear the treeview & write the supplied data rows to it."""
The rows argument will take a list of the dict data types, such as what is returned from model. The idea is that the controller will fetch a list from the model and then pass it to this method.
Before refilling Treeview, we need to empty it:
for row in self.treeview.get_children():
self.treeview.delete(row)
The get_children() method of Treeview returns a list of every row's iid. We're iterating this list, passing each iid to the Treeview.delete() method, which, as you'd expect, deletes the row.
With the Treeview cleared, we can ...
Read now
Unlock full access