def render(self, data, *, label=None): # create the graph graphattrs = self.graphattrs.copy() if label is not None: graphattrs['label'] = self._escape_dot_label(label) graph = gv.Digraph(graph_attr = graphattrs, node_attr = self.nodeattrs, edge_attr = self.edgeattrs) # recursively draw all the nodes and edges self._graph = graph self._rendered_nodes = set() self._render_node(data) self._graph = None self._rendered_nodes = None # display the graph graph.format = "pdf" graph.view() subprocess.Popen(['xdg-open', "test.pdf"])