Skip to content Skip to sidebar Skip to footer

Adding Label To An Edge Of A Graph In Nodebox Opnegl

I am trying to add a label to each edge in my Graph, below: Basically the above with labels for each edge at the center: I've tried to add a label when I add an edge to each grap

Solution 1:

As you can see in the source there is no argument labelfor add_edge. (search for class Edge(object):)

The best way i can see is to create your own MyEdge Class derived from the official Edge Class which adds a Text (the label) using

txt = Text(str, x=0, y=0, width=None, height=None)

or

textpath(string, x=0, y=0, fontname=None, fontsize=None, fontweight=None)

in the draw() Method.

EDIT Mind the add_edge Methods docstring:

defadd_edge(self, id1, id2, *args, **kwargs):
    """ Appends a new Edge to the graph.
        An optional base parameter can be used to pass a subclass of Edge:
        Graph.add_edge("cold", "winter", base=IsPropertyOf)
    """

Post a Comment for "Adding Label To An Edge Of A Graph In Nodebox Opnegl"