问题
Hi I would like to create a wxpython application with a window where I can create a network graph. I have heard (never used) of graphviz and NetworkX, but it seems to me that they only creates graph given some input data. I would like to do the opposite - i.e., create drag and drop nodes and links from a pallete menu. The nodes and links should be right-clickable with context menu popups. Eg., I should be able to right click a node and click "properties" in context menu - where I can fill in ip address, number of ports, their mac addresses etc.
I believe graphviz will not allow me to do that. Is there any good package to do this ? Must be free / open-source.
回答1:
Take a look at the wx.lib.ogl package. It has the basics of what you would need to build diagrams of shapes, labels, lines, arrows, etc. and you can allow the user to interact with them to move them around the window, etc. It is not perfect, but people are using it for this type of thing quite a bit.
Another possibility for you might be wx.lib.floatcanvas. They both have their strengths and weaknesses, so it really depends on which is the best fit for your needs.
来源:https://stackoverflow.com/questions/4447658/wxpython-network-graph-clickable-with-context-menu-any-pkgs