|
XDot
Interactive viewer for Graphviz dot files
Aboutxdot.py is an interactive viewer for graphs written in Graphviz's dot language. It uses internally the graphviz's xdot output format as an intermediate format, and PyGTK and Cairo for rendering. xdot.py can be used either as a standalone application from command line, or as a library embedded in your python application. StatusFeatures
Changelog
Known Issues
ScreenshotsRequirementsWindows users
Debian/Ubuntu users
apt-get install python-gtk2 graphviz UsageCommand LineUsage:
xdot.py [file]
Options:
--version show program's version number and exit
-h, --help show this help message and exit
-f FILTER, --filter=FILTER
graphviz filter: dot, neato, twopi, circo, or fdp
[default: dot]If no input file is given then it will read the dot graph from the standard input. Shortcuts
EmbeddingSample code#!/usr/bin/env python
import gtk
import gtk.gdk
import xdot
class MyDotWindow(xdot.DotWindow):
def __init__(self):
xdot.DotWindow.__init__(self)
self.widget.connect('clicked', self.on_url_clicked)
def on_url_clicked(self, widget, url, event):
dialog = gtk.MessageDialog(
parent = self,
buttons = gtk.BUTTONS_OK,
message_format="%s clicked" % url)
dialog.connect('response', lambda dialog, response: dialog.destroy())
dialog.run()
return True
dotcode = """
digraph G {
Hello [URL="http://en.wikipedia.org/wiki/Hello"]
World [URL="http://en.wikipedia.org/wiki/World"]
Hello -> World
}
"""
def main():
window = MyDotWindow()
window.set_dotcode(dotcode)
window.connect('destroy', gtk.main_quit)
gtk.main()
if __name__ == '__main__':
main()ResultDownloadLinks
|
Sign in to add a comment




Having spent today immersed in pypy's dotviewer's internals I can tell that it doesn't use 'xdot' as the intermediate format; it uses the simplest and most crippled 'plain' format, and that causes problems.
This is so cool! I have experimentally compiled Graphviz for the Maemo operating system, put it on my Nokia N800, and then used 'xDot' to successfully navigate around some sample 'dot' files with it! To enable the use of the device's zoom buttons, I added some F7 and F8 'keysymbs'. Does xDot use the GPL license?
darethehair,
XDot uses the LGPL license, which means you can use it in closed source projects as long as the xdot module itself is kept open source. Of course, it is difficult to conceive closed source python software unless one goes out of its way and uses byte code, or code obfuscators, etc.
I do like this tool. Well done! I'm actually using this inside a wxPython application of all places, as this seems to be a nice alternative to the wx floatcanvas package.
The only comment I have is that shapefile nodes aren't supported, as XDotAttrParser::parse writes "unknown xdot opcode 'I' " when it encounters the draw field . If I had the time to dig around the internals (alas there are only 24 in the day) I would have a shot at trying to implement this myself. In the meantime, if you are looking for more xdot features to implement, you could do a lot worse than add shapefile support :-)
Really good !!!
I now can see my UML that I create parsing PHP files easier than before. Now you only have to implement an editor on the left :)
I downloaded version 0.4 from SVN. But the sample.py have not worked for me earlier. I changed two rows in 3 places (filled=True; handle_ellipse; EllipseShape?), and now it works well. (Upper rows are the good rows.)
I like it.
Thanks arpad. I really need to make a testsuite to catch this kind of problems earlier on.
Please provide some more samples.
How do I add a node? Does it have to re-process all the code i want to add a node? Can I remove a node?
eldmannen,
Xdot.py is just a viewer for graphviz's dot language. It does not support editing. To change the graph you'll need to regenerate another dot file.
See http://www.graphviz.org/Documentation.php for the dot languange documentation and examples; and see http://code.google.com/p/yapgvb/ , http://software.inl.fr/trac/wiki/GvGen , and http://code.google.com/p/pydot/ for python libraries that can help generate those graphs in the dot language.
Hey very cool and fairly lightweight (no JAVA yaaay \o/ :D) dot viewer. I've made a tiny patch that reloads the file on the 'r' key and I find it quite useful :) It would be even nicer if it was able to watch the file for changes automatically. Maybe I'll add that later.
Great tool, very light weight. I hacked in a "Find" button to search through node text. I've never used gtk or python before so its probably a little rough, but it does work. Any where I can send code back to contribute?
butterfoss,
Please open an issue and attached a patch or the modified source code.
Simplemente, es perfecto. Justo lo que andaba buscando.
It doesn't work for me - this is what happened... Graham
graham@graham-laptop:~$ sudo apt-get install python-gtk2 graphviz sudo? password for graham: Reading package lists... Done Building dependency tree Reading state information... Done python-gtk2 is already the newest version. graphviz is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. graham@graham-laptop:~$ cd bin graham@graham-laptop:~/bin$ xdot.py test2.dot Traceback (most recent call last):
OSError: 32? Broken pipe graham@graham-laptop:~/bin$Hi,
thanks very much for this dot visor but how can I handle node clicks? I'd like to click in some node and call some method. Is it possible?
Regards
Very usable stuff.
I have based a profiler visualizer SleepyGraph on XDot: http://sleepygraph.sourceforge.net/
It visualizes measurements from VerySleepy profiler.
To adapt SleepyGraph to another profiler input, just 3 classes need to be modified - Symbol, Callstack and Database - to be able to parse/load inputs of different format.
kaskaras,
The sample code above does what you want.
gandalfmeister,
Broken pipe means that the dot process died prematurely. Perhaps graphviz is not in the path, or properly installed, or the dot input is wrong in some way.
Can this be converted to an editor? Do you have any plans for that?
a.tarun,
No, no plans to convert into an editor. Most use I have for xdot.py is just visualization of graphviz graphs generated automatically from other data.