问题
Is there any tool which helps me create an interactive user interface for generating graphs using iGraphs for python? For instance can I use pyQt along with Igraph?
回答1:
The Python interface of igraph uses Cairo as the drawing backend, so it can draw graphs on any surface that Cairo supports. It seems like someone else has managed to connect igraph's drawing surface to a gtk.DrawingArea
, so that's one possibility if you are using PyGtk.
As for PyQt and other drawing toolkits, I'm not sure but the solution is probably similar to what has been done with the gtk.DrawingArea
in PyGtk; basically you subclass a canvas widget from your graphics toolkit, obtain a handle to the raw memory block where the contents of the canvas is drawn by the graphics toolkit, wrap that memory block in a cairo.ImageSurface
with the appropriate width, height and bit depth, and then ask igraph to draw onto that surface by constructing an igraph.drawing.Plot
object that uses the surface. Sorry for not being able to be more specific, but it really depends on the exact graphics toolkit that you plan to use, and I'm not too familiar with either PyGtk or PyQt.
来源:https://stackoverflow.com/questions/17025690/interactive-ui-with-igraph