[GRASS-SVN] r29696 - in grass/trunk/gui/wxpython: . gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Jan 13 11:42:24 EST 2008


Author: martinl
Date: 2008-01-13 11:42:24 -0500 (Sun, 13 Jan 2008)
New Revision: 29696

Modified:
   grass/trunk/gui/wxpython/gis_set.py
   grass/trunk/gui/wxpython/gui_modules/utils.py
   grass/trunk/gui/wxpython/wxgui.py
Log:
wxGUI: check wxPython version (note >= 2.8.1.1 is required)

Modified: grass/trunk/gui/wxpython/gis_set.py
===================================================================
--- grass/trunk/gui/wxpython/gis_set.py	2008-01-13 13:49:50 UTC (rev 29695)
+++ grass/trunk/gui/wxpython/gis_set.py	2008-01-13 16:42:24 UTC (rev 29696)
@@ -25,7 +25,9 @@
 import glob
 import shutil
 
-import wx
+from gui_modules import utils
+
+utils.ImportWx()
 import wx.html
 import wx.lib.rcsizer as rcs
 import wx.lib.filebrowsebutton as filebrowse

Modified: grass/trunk/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/utils.py	2008-01-13 13:49:50 UTC (rev 29695)
+++ grass/trunk/gui/wxpython/gui_modules/utils.py	2008-01-13 16:42:24 UTC (rev 29696)
@@ -1,31 +1,34 @@
 """
-MODULE: utils.py
+ at package utils.py
 
-CLASSES:
-    * GetTempfile
+ at brief Misc utilities for GRASS wxPython GUI
 
-PURPOSE: Misc utilities for GRASS wxPython GUI
+(C) 2007-2008 by the GRASS Development Team
 
-AUTHORS: The GRASS Development Team
+This program is free software under the GNU General Public
+License (>=v2). Read the file COPYING that comes with GRASS
+for details.
 
-COPYRIGHT: (C) 2007 by the GRASS Development Team
-         This program is free software under the GNU General Public
-         License (>=v2). Read the file COPYING that comes with GRASS
-         for details.
+ at author Martin Landa, Jachym Cepicky
+
+ at date 2007-2008
 """
 
 import os
+import sys
 
+gmpath = os.path.join(os.getenv("GISBASE"), "etc", "wx", "gui_modules")
+sys.path.append(gmpath)
+
 import gcmd
 
 def GetTempfile(pref=None):
     """
     Creates GRASS temporary file using defined prefix.
 
-    Parameters:
-        pref: prefer the given path
-    Returns:
-        Path to file name (string) or None
+    @param pref prefer the given path
+
+    @return Path to file name (string) or None
     """
 
     tempfileCmd = gcmd.Command(["g.tempfile",
@@ -43,7 +46,13 @@
         return Node
 
 def GetLayerNameFromCmd(dcmd):
-    """Get layer name from GRASS command"""
+    """Get layer name from GRASS command
+
+    @param dcmd GRASS command (given as list)
+
+    @return map name
+    @return '' if no map name found in command
+    """
     mapname = ''
     for item in dcmd:
         if 'map=' in item:
@@ -72,6 +81,11 @@
     """Convert list of category number to range(s)
 
     Used for example for d.vect cats=[range]
+
+    @param cats category list
+
+    @return category range string
+    @return '' on error
     """
 
     catstr = ''
@@ -100,3 +114,22 @@
             i += 1
         
     return catstr.strip(',')
+
+def ImportWx():
+    """Try to import wx module and check its version"""
+    majorVersion = 2.8
+    minorVersion = 1.1
+    try:
+        import wx
+        version = wx.__version__
+        if float(version[:3]) < majorVersion:
+            raise ValueError('You are using wxPython version %s' % str(version))
+        if float(version[:3]) == 2.8 and \
+                float(version[4:]) < minorVersion:
+            raise ValueError('You are using wxPython version %s' % str(version))
+
+    except (ImportError, ValueError), e:
+        print >> sys.stderr, 'ERROR: ' + str(e) + \
+            '. wxPython >= %s.%s is required. Detailed information in README file.' % \
+            (str(majorVersion), str(minorVersion))
+        sys.exit(1)

Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py	2008-01-13 13:49:50 UTC (rev 29695)
+++ grass/trunk/gui/wxpython/wxgui.py	2008-01-13 16:42:24 UTC (rev 29696)
@@ -38,7 +38,20 @@
 HandlerBase=xml.sax.handler.ContentHandler
 from xml.sax import make_parser
 
-import wx
+import gui_modules
+gmpath = gui_modules.__path__[0]
+sys.path.append(gmpath)
+
+import images
+imagepath = images.__path__[0]
+sys.path.append(imagepath)
+
+import icons
+gmpath = icons.__path__[0]
+sys.path.append(gmpath)
+
+import gui_modules.utils as utils
+utils.ImportWx()
 import wx.aui
 import wx.combo
 import wx.html
@@ -51,18 +64,6 @@
 except:
     import compat.subprocess as subprocess
 
-import gui_modules
-gmpath = gui_modules.__path__[0]
-sys.path.append(gmpath)
-
-import images
-imagepath = images.__path__[0]
-sys.path.append(imagepath)
-
-import icons
-gmpath = icons.__path__[0]
-sys.path.append(gmpath)
-
 import gui_modules.wxgui_utils as wxgui_utils
 import gui_modules.mapdisp as mapdisp
 import gui_modules.menudata as menudata
@@ -72,7 +73,6 @@
 import gui_modules.histogram as histogram
 import gui_modules.profile as profile
 import gui_modules.rules as rules
-import gui_modules.utils as utils
 import gui_modules.gcmd as gcmd
 import gui_modules.georect as georect
 import gui_modules.dbm as dbm



More information about the grass-commit mailing list