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

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
variable.
parent fbf26825
......@@ -44,6 +44,7 @@ graph_tool_communitydir = $(MOD_DIR)/community
graph_tool_draw_PYTHON = \
draw/__init__.py \
draw/cairo_draw.py \
draw/gtk_draw.py \
draw/graphviz_draw.py
graph_tool_draw_DATA = \
draw/graph-tool-logo.svg
......
......@@ -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",
"GraphWindow"]
"cairo_draw"]
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.,
verbose)
return pos
from cairo_draw import graph_draw, GraphWidget, GraphWindow, \
interactive_window, cairo_draw
from cairo_draw import graph_draw, cairo_draw
try:
from cairo_draw import GraphWidget, GraphWindow, \
interactive_window
__all__ += ["interactive_window", "GraphWidget", "GraphWindow"]
except ImportError:
pass
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