Commit 7ea3821e authored by Tiago Peixoto's avatar Tiago Peixoto

Slightly refactor draw module to only optionally depend on GTK+

This implements a graceful fallback in case GTK cannot be loaded, which
can (currently) happen simply by not having a environment DISPLAY
parent fbf26825
......@@ -44,6 +44,7 @@ graph_tool_communitydir = $(MOD_DIR)/community
graph_tool_draw_PYTHON = \
draw/ \
draw/ \
draw/ \
graph_tool_draw_DATA = \
......@@ -71,7 +71,6 @@ from .. stats import label_parallel_edges
import numpy.random
from numpy import sqrt
import sys
import warnings
from .. dl_import import dl_import
dl_import("import libgraph_tool_layout")
......@@ -79,8 +78,7 @@ dl_import("import libgraph_tool_layout")
__all__ = ["graph_draw", "graphviz_draw", "fruchterman_reingold_layout",
"arf_layout", "sfdp_layout", "random_layout",
"interactive_window", "cairo_draw", "GraphWidget",
def random_layout(g, shape=None, pos=None, dim=2):
......@@ -586,7 +584,13 @@ def sfdp_layout(g, vweight=None, eweight=None, pin=None, C=0.2, K=None, p=2.,
return pos
from cairo_draw import graph_draw, GraphWidget, GraphWindow, \
interactive_window, cairo_draw
from cairo_draw import graph_draw, cairo_draw
from cairo_draw import GraphWidget, GraphWindow, \
__all__ += ["interactive_window", "GraphWidget", "GraphWindow"]
except ImportError:
from graphviz_draw import graphviz_draw
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment