From 2474e2a3e38794cd32ef064594bba2d26c80aa36 Mon Sep 17 00:00:00 2001
From: "(no author)" <(no author)@8a9318a1-56ba-4d59-b755-99d26321be01>
Date: Thu, 3 May 2012 21:22:26 +0000
Subject: [PATCH] changing how the gui is loaded to avoid pyqt4 dependencies
 unless you're running the gui

git-svn-id: https://svn.ssec.wisc.edu/repos/glance/trunk@177 8a9318a1-56ba-4d59-b755-99d26321be01
---
 pyglance/glance/compare.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/pyglance/glance/compare.py b/pyglance/glance/compare.py
index 6283932..da7e817 100644
--- a/pyglance/glance/compare.py
+++ b/pyglance/glance/compare.py
@@ -19,8 +19,14 @@ from subprocess import check_call as sh
 from urllib import quote
 
 import matplotlib
+# this is a hack to keep glance from needing pyqt unless you run the gui
 if "gui" in sys.argv[1:] :
-    matplotlib.use('Qt4Agg')
+    try :
+        matplotlib.use('Qt4Agg')
+        import glance.gui_controller as gui_control
+    except ImportError :
+        print ("*** Unable to import PyQt4. Please install PyQt4 and add it to your PYTHONPATH in order to use the Glance GUI. ***")
+        raise
 else :
     matplotlib.use('Agg')
 
@@ -33,8 +39,6 @@ import glance.stats  as statistics
 import glance.plotcreatefns as plotcreate
 import glance.collocation   as collocation
 
-import glance.gui_controller as gui_control
-
 LOG = logging.getLogger(__name__)
 
 # these are the built in defaults for the settings
-- 
GitLab