Skip to content
David Llewellyn-Jones edited this page Aug 20, 2013 · 1 revision

Dandelion is supplied with several client libraries that can be used to control the visualisation. At present the following languages are supported.

Each of these includes both a client library and a simple demonstration interface to give an idea about how it can be used. However, in general the use of each is very straightforward.

For example, the following Python script imports the dlclient python library and uses it to create two nodes with a link between them.

import dlclient
dlclient = dlclient.DlClient()
dlclient.setHost("localhost")
dlclient.clear()
dlclient.addNode("First")
dlclient.addNode("Second")
dlclient.addLinkNamed("Link", "First", "Second")
dlclient.quit()

As you can see, it's pretty straightforward code. Here's the result of running the code shown in the Dandelion server window.

Two nodes created programmatically using Python code.

Although the code is hopefully fairly self-explanatory, to cover it in full there's a version of the same code below with each line annotated.

#!/usr/bin/env python

import dlclient

# Create a DlClient object providing the functionality we need
dlclient = dlclient.DlClient()

# We're connecting to localhost, but this could be any machine on the network
dlclient.setHost("localhost")

# Clear the current arrangement of nodes
dlclient.clear()

# Create the first node
dlclient.addNode("First")

# Create the second node
dlclient.addNode("Second")

# Connect the two nodes together
dlclient.addLinkNamed("Link", "First", "Second")

# Close the network connection
dlclient.quit()

This demonstrates how to use the Python client library. The Java and C# library classes are similarly easy to use.

For C there's also a very straightfoward library that can be used. The only catch is that it currently relies on glib and gnet. This works fine if you're developing a GTK application, but may cause difficulties in other scenarios. In future we're therefore aiming to relax these dependencies.

Clone this wiki locally