[GRASS-SVN] r69799 - in grass/branches/releasebranch_7_0/gui/wxpython: gui_core iclass wxplot

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Nov 13 05:17:50 PST 2016


Author: annakrat
Date: 2016-11-13 05:17:50 -0800 (Sun, 13 Nov 2016)
New Revision: 69799

Modified:
   grass/branches/releasebranch_7_0/gui/wxpython/gui_core/wxlibplot.py
   grass/branches/releasebranch_7_0/gui/wxpython/iclass/plots.py
   grass/branches/releasebranch_7_0/gui/wxpython/wxplot/base.py
   grass/branches/releasebranch_7_0/gui/wxpython/wxplot/histogram.py
   grass/branches/releasebranch_7_0/gui/wxpython/wxplot/profile.py
   grass/branches/releasebranch_7_0/gui/wxpython/wxplot/scatter.py
Log:
wxGUI/plot: use local wxlibplot for all wxPython versions, their old import of numpy does not work anymore (merge from trunk, r69797)

Modified: grass/branches/releasebranch_7_0/gui/wxpython/gui_core/wxlibplot.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/gui_core/wxlibplot.py	2016-11-13 13:11:56 UTC (rev 69798)
+++ grass/branches/releasebranch_7_0/gui/wxpython/gui_core/wxlibplot.py	2016-11-13 13:17:50 UTC (rev 69799)
@@ -118,17 +118,20 @@
 import wx
 
 # Needs NumPy
-try:
-    import numpy as np
-except:
-    msg = """
-    This module requires the NumPy module, which could not be
-    imported.  It probably is not installed (it's not part of the
-    standard Python distribution). See the Numeric Python site
-    (http://numpy.scipy.org) for information on downloading source or
-    binaries."""
-    raise ImportError("NumPy not found.\n" + msg)
+import numpy as np
 
+from core.globalvar import CheckWxVersion
+if CheckWxVersion([3, 0, 0]):
+    from wx import PENSTYLE_SOLID
+    from wx import PENSTYLE_DOT_DASH
+    from wx import PENSTYLE_DOT
+    from wx import BRUSHSTYLE_SOLID
+    from wx import BRUSHSTYLE_TRANSPARENT
+else:
+    from wx import SOLID as PENSTYLE_SOLID
+    from wx import SOLID as BRUSHSTYLE_SOLID
+    from wx import DOT_DASH as PENSTYLE_DOT_DASH
+    from wx import TRANSPARENT as BRUSHSTYLE_TRANSPARENT
 
 #
 # Plotting classes...
@@ -230,7 +233,7 @@
 
     _attributes = {'colour': 'black',
                    'width': 1,
-                   'style': wx.PENSTYLE_SOLID,
+                   'style': PENSTYLE_SOLID,
                    'legend': ''}
 
     def __init__(self, points, **attr):
@@ -280,7 +283,7 @@
 
     _attributes = {'colour': 'black',
                    'width': 1,
-                   'style': wx.PENSTYLE_SOLID,
+                   'style': PENSTYLE_SOLID,
                    'legend': ''}
 
     def __init__(self, points, **attr):
@@ -326,7 +329,7 @@
                    'width': 1,
                    'size': 2,
                    'fillcolour': None,
-                   'fillstyle': wx.BRUSHSTYLE_SOLID,
+                   'fillstyle': BRUSHSTYLE_SOLID,
                    'marker': 'circle',
                    'legend': ''}
 
@@ -1179,7 +1182,7 @@
         if dc is None:
             # sets new dc and clears it
             dc = wx.BufferedDC(wx.ClientDC(self.canvas), self._Buffer)
-            bbr = wx.Brush(self.GetBackgroundColour(), wx.BRUSHSTYLE_SOLID)
+            bbr = wx.Brush(self.GetBackgroundColour(), BRUSHSTYLE_SOLID)
             dc.SetBackground(bbr)
             dc.SetBackgroundMode(wx.SOLID)
             dc.Clear()
@@ -1696,7 +1699,7 @@
         # draw rectangle
         dc = wx.ClientDC(self.canvas)
         dc.SetPen(wx.Pen(wx.BLACK))
-        dc.SetBrush(wx.Brush(wx.WHITE, wx.BRUSHSTYLE_TRANSPARENT))
+        dc.SetBrush(wx.Brush(wx.WHITE, BRUSHSTYLE_TRANSPARENT))
         dc.SetLogicalFunction(wx.INVERT)
         dc.DrawRectangle(ptx, pty, rectWidth, rectHeight)
         dc.SetLogicalFunction(wx.COPY)
@@ -2142,14 +2145,14 @@
     data1.shape = (100, 2)
     data1[:, 1] = np.sin(data1[:, 0])
     line1 = PolySpline(
-        data1, legend='Green Line', colour='green', width=6, style=wx.PENSTYLE_DOT)
+        data1, legend='Green Line', colour='green', width=6, style=PENSTYLE_DOT)
 
     # 50 points cos function, plotted as red dot-dash
     data1 = 2. * np.pi * np.arange(100) / 100.
     data1.shape = (50, 2)
     data1[:, 1] = np.cos(data1[:, 0])
     line2 = PolySpline(
-        data1, legend='Red Line', colour='red', width=3, style=wx.PENSTYLE_DOT_DASH)
+        data1, legend='Red Line', colour='red', width=3, style=PENSTYLE_DOT_DASH)
 
     # A few more points...
     pi = np.pi
@@ -2352,7 +2355,7 @@
         """
         # ----------
         dc.SetPen(wx.Pen(wx.BLACK))
-        dc.SetBrush(wx.Brush(wx.BLACK, wx.BRUSHSTYLE_SOLID))
+        dc.SetBrush(wx.Brush(wx.BLACK, BRUSHSTYLE_SOLID))
 
         sx, sy = mDataDict["scaledXY"]  # scaled x,y of closest point
         # 10by10 square centered on point

Modified: grass/branches/releasebranch_7_0/gui/wxpython/iclass/plots.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/iclass/plots.py	2016-11-13 13:11:56 UTC (rev 69798)
+++ grass/branches/releasebranch_7_0/gui/wxpython/iclass/plots.py	2016-11-13 13:17:50 UTC (rev 69799)
@@ -16,14 +16,8 @@
 """
 
 import wx
-from core.globalvar import CheckWxVersion
-try:
-    if CheckWxVersion(version=[3, 0, 0]):
-        import gui_core.wxlibplot as plot
-    else:
-        import wx.lib.plot as plot
-except ImportError as e:
-    print >> sys.stderr, e
+
+import gui_core.wxlibplot as plot
 import wx.lib.scrolledpanel as scrolled
 from core.utils import _
 from core.gcmd import GError

Modified: grass/branches/releasebranch_7_0/gui/wxpython/wxplot/base.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/wxplot/base.py	2016-11-13 13:11:56 UTC (rev 69798)
+++ grass/branches/releasebranch_7_0/gui/wxpython/wxplot/base.py	2016-11-13 13:17:50 UTC (rev 69799)
@@ -19,20 +19,13 @@
 import sys
 
 import wx
-from core.globalvar import CheckWxVersion
-try:
-    if CheckWxVersion(version=[3, 0, 0]):
-        import gui_core.wxlibplot as plot
-    else:
-        import wx.lib.plot as plot
-except ImportError as e:
-    print >> sys.stderr, e
 
-from core.globalvar    import ICONDIR
-from core.settings     import UserSettings
-from wxplot.dialogs    import TextDialog, OptDialog
-from core.render       import Map
-from icons.icon        import MetaIcon
+import gui_core.wxlibplot as plot
+from core.globalvar import ICONDIR
+from core.settings import UserSettings
+from wxplot.dialogs import TextDialog, OptDialog
+from core.render import Map
+from icons.icon import MetaIcon
 from gui_core.toolbars import BaseIcons
 from core.utils import _
 

Modified: grass/branches/releasebranch_7_0/gui/wxpython/wxplot/histogram.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/wxplot/histogram.py	2016-11-13 13:11:56 UTC (rev 69798)
+++ grass/branches/releasebranch_7_0/gui/wxpython/wxplot/histogram.py	2016-11-13 13:17:50 UTC (rev 69799)
@@ -18,17 +18,9 @@
 import sys
 
 import wx
-from core.globalvar import CheckWxVersion
-try:
-    if CheckWxVersion(version=[3, 0, 0]):
-        import gui_core.wxlibplot as plot
-    else:
-        import wx.lib.plot as plot
-except ImportError as e:
-    print >> sys.stderr, e
 
 import grass.script as grass
-
+import gui_core.wxlibplot as plot
 from gui_core.toolbars import BaseToolbar, BaseIcons
 from wxplot.base       import BasePlotFrame, PlotIcons
 from wxplot.dialogs    import HistRasterDialog, PlotStatsFrame

Modified: grass/branches/releasebranch_7_0/gui/wxpython/wxplot/profile.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/wxplot/profile.py	2016-11-13 13:11:56 UTC (rev 69798)
+++ grass/branches/releasebranch_7_0/gui/wxpython/wxplot/profile.py	2016-11-13 13:17:50 UTC (rev 69799)
@@ -18,30 +18,13 @@
 import os
 import sys
 import math
+import numpy
 
 import wx
-from core.globalvar import CheckWxVersion
-try:
-    if CheckWxVersion(version=[3, 0, 0]):
-        import gui_core.wxlibplot as plot
-    else:
-        import wx.lib.plot as plot
-except ImportError as e:
-    print >> sys.stderr, e
 
+import gui_core.wxlibplot as plot
 import grass.script as grass
 from core.utils import _
-
-try:
-    import numpy
-except ImportError:
-    msg = _("This module requires the NumPy module, which could not be "
-            "imported. It probably is not installed (it's not part of the "
-            "standard Python distribution). See the Numeric Python site "
-            "(http://numpy.scipy.org) for information on downloading source or "
-            "binaries.")
-    print >> sys.stderr, "wxplot.py: " + msg
-
 from wxplot.base       import BasePlotFrame, PlotIcons
 from gui_core.toolbars import BaseToolbar, BaseIcons
 from wxplot.dialogs    import ProfileRasterDialog, PlotStatsFrame

Modified: grass/branches/releasebranch_7_0/gui/wxpython/wxplot/scatter.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/wxplot/scatter.py	2016-11-13 13:11:56 UTC (rev 69798)
+++ grass/branches/releasebranch_7_0/gui/wxpython/wxplot/scatter.py	2016-11-13 13:17:50 UTC (rev 69799)
@@ -18,17 +18,9 @@
 import sys
 
 import wx
-from core.globalvar import CheckWxVersion
-try:
-    if CheckWxVersion(version=[3, 0, 0]):
-        import gui_core.wxlibplot as plot
-    else:
-        import wx.lib.plot as plot
-except ImportError as e:
-    print >> sys.stderr, e
 
 import grass.script as grass
-
+import gui_core.wxlibplot as plot
 from wxplot.base       import BasePlotFrame, PlotIcons
 from gui_core.toolbars import BaseToolbar, BaseIcons
 from wxplot.dialogs    import ScatterRasterDialog, PlotStatsFrame



More information about the grass-commit mailing list