I am trying to use Nodebox Graph on Ubuntu and python 2.7.
So I got Nodebox OpenGL: http://www.cityinabottle.org/nodebox/
Node graph: https://www.nodebox.net/code/index.php/Graph
I tried to run their main example 1:
graph = ximport("graph") size(500, 500) g = graph.create() # Create some relations. g.add_edge("roof" , "house") g.add_edge("garden" , "house") g.add_edge("room" , "house") g.add_edge("kitchen" , "room") g.add_edge("bedroom" , "room") g.add_edge("bathroom" , "room") g.add_edge("living room" , "room") g.add_edge("sofa" , "living room") g.add_edge("table" , "living room") # Calculate a good layout. g.solve() # Apply default rules for node colors and size, # for example, important nodes become blue. g.styles.apply() # Draw the graph, indicating the direction of each relation # and the two nodes that get the most traffic. g.draw( directed=True, traffic=1 )
This does not work because ximport is not defined, it is determined only by nodebox, so instead I tried two things, first doing a regular import import schedule for the second, putting the ximport function from nodebox in my code:
def ximport(library): from sys import modules library = __import__(library) library._ctx = modules[__name__] return library graph = ximport("graph") size(500, 500) g = graph.create() # Create some relations. g.add_edge("roof" , "house") g.add_edge("garden" , "house") g.add_edge("room" , "house") g.add_edge("kitchen" , "room") g.add_edge("bedroom" , "room") g.add_edge("bathroom" , "room") g.add_edge("living room" , "room") g.add_edge("sofa" , "living room") g.add_edge("table" , "living room") # Calculate a good layout. g.solve() # Apply default rules for node colors and size, # for example, important nodes become blue. g.styles.apply() # Draw the graph, indicating the direction of each relation # and the two nodes that get the most traffic. g.draw( directed=True, traffic=1 )
This still does not work, because now the size of the function is not recognized. If I just comment on the size, I get the following error:
self.x = _ctx.WIDTH - max.x*self.d - min_.x*self.d
AttributeError: object "NoneType" does not have attribute "WIDTH"
What should I do?
This question may be similar:
Pydev Nodebox: "AttributeError: 'NoneType' does not have the 'WIDTH' attribute"
but this answer doesnβt help me at all.