The Treeview is a ttk widget designed to show columns of data in a hierarchical structure.
Perhaps the best example of this kind of data is a filesystem tree:
- Each row can represent a file or directory
- Each directory can contain additional files or directories
- Each row can have additional data properties, such as permissions, size, or ownership information
To explore how Treeview works, we'll create a simple file browser with some help from pathlib.
In previous chapters, we used os.path to work with file paths. pathlib is a new addition to the Python 3 standard library that provides a more object-oriented approach to paths.
Open a new file called treeview_demo.py and start with this template:
import tkinter as tk from ...