def pretty_print(self, pager=False): """Draw the tree in the terminal window.""" s = StringIO() for root in self.roots: self._pretty_print_subtree(root, string=s) s = s.getvalue().rstrip() if pager: proc = subprocess.Popen(["less"], stdin=subprocess.PIPE) proc.communicate(input=s.encode("utf-8")) else: print(s)