Przeglądaj źródła

wxGUI, d.rast.edit: remove 'wxversion' module (#713)

* d.rast.edit, wxpyimgview, wxGUI globalvar: remove 'wxversion' module

* wxGUI globalvar: remove obsolete 'wxPython3' var
Tomas Zigo 4 lat temu
rodzic
commit
1245b5c998

+ 8 - 27
gui/wxpython/core/globalvar.py

@@ -34,6 +34,8 @@ from grass.script.core import get_commands
 
 
 from core.debug import Debug
 from core.debug import Debug
 
 
+WXPY3_MIN_VERSION = [4, 0, 0, 0]
+
 
 
 def parse_version_string(version):
 def parse_version_string(version):
     """Parse version number, return three numbers as list
     """Parse version number, return three numbers as list
@@ -88,44 +90,24 @@ def CheckWxVersion(version):
     return True
     return True
 
 
 
 
-def CheckForWx(forceVersion=os.getenv('GRASS_WXVERSION', None)):
-    """Try to import wx module and check its version
-
-    :param forceVersion: force wxPython version, eg. '2.8'
-    """
+def CheckForWx():
+    """Try to import wx module"""
     if 'wx' in sys.modules.keys():
     if 'wx' in sys.modules.keys():
         return
         return
 
 
-    minVersion = [2, 8, 10, 1]
     try:
     try:
-        try:
-            # Note that Phoenix doesn't have wxversion anymore
-            import wxversion
-        except ImportError as e:
-            # if there is no wx raises ImportError
-            import wx
-            return
-        if forceVersion:
-            wxversion.select(forceVersion)
-        wxversion.ensureMinimal(str(minVersion[0]) + '.' + str(minVersion[1]))
-        import wx  # noqa: F811
+        import wx
         version = parse_version_string(wx.__version__)
         version = parse_version_string(wx.__version__)
-
-        if version < minVersion:
+        if version < WXPY3_MIN_VERSION:
             raise ValueError(
             raise ValueError(
                 "Your wxPython version is {}".format(wx.__version__))
                 "Your wxPython version is {}".format(wx.__version__))
-
+        return
     except ImportError as e:
     except ImportError as e:
-        print('ERROR: wxGUI requires wxPython. %s' % str(e),
+        print('ERROR: wxGUI requires wxPython. {}'.format(e),
               file=sys.stderr)
               file=sys.stderr)
         print('You can still use GRASS GIS modules in'
         print('You can still use GRASS GIS modules in'
               ' the command line or in Python.', file=sys.stderr)
               ' the command line or in Python.', file=sys.stderr)
         sys.exit(1)
         sys.exit(1)
-    except (ValueError, wxversion.VersionError) as e:
-        message = "ERROR: wxGUI requires wxPython >= {version}: {error}".format(
-            version=version_as_string(minVersion), error=e)
-        print(message, file=sys.stderr)
-        sys.exit(1)
     except locale.Error as e:
     except locale.Error as e:
         print("Unable to set locale:", e, file=sys.stderr)
         print("Unable to set locale:", e, file=sys.stderr)
         os.environ['LC_ALL'] = ''
         os.environ['LC_ALL'] = ''
@@ -263,7 +245,6 @@ toolbarSize = (24, 24)
 
 
 """@Check version of wxPython, use agwStyle for 2.8.11+"""
 """@Check version of wxPython, use agwStyle for 2.8.11+"""
 hasAgw = CheckWxVersion([2, 8, 11, 0])
 hasAgw = CheckWxVersion([2, 8, 11, 0])
-wxPython3 = CheckWxVersion([3, 0, 0, 0])
 wxPythonPhoenix = CheckWxPhoenix()
 wxPythonPhoenix = CheckWxPhoenix()
 
 
 gtk3 = True if 'gtk3' in wx.PlatformInfo else False
 gtk3 = True if 'gtk3' in wx.PlatformInfo else False

+ 1 - 2
gui/wxpython/mapdisp/frame.py

@@ -226,8 +226,7 @@ class MapFrame(SingleMapFrame):
 
 
         # create statusbar and its manager
         # create statusbar and its manager
         statusbar = self.CreateStatusBar(number=4, style=0)
         statusbar = self.CreateStatusBar(number=4, style=0)
-        if globalvar.wxPython3:
-            statusbar.SetMinHeight(24)
+        statusbar.SetMinHeight(24)
         statusbar.SetStatusWidths([-5, -2, -1, -1])
         statusbar.SetStatusWidths([-5, -2, -1, -1])
         self.statusbarManager = sb.SbManager(
         self.statusbarManager = sb.SbManager(
             mapframe=self, statusbar=statusbar)
             mapframe=self, statusbar=statusbar)

+ 1 - 3
gui/wxpython/mapswipe/frame.py

@@ -23,7 +23,6 @@ import grass.script as grass
 from gui_core.mapdisp import DoubleMapFrame
 from gui_core.mapdisp import DoubleMapFrame
 from gui_core.dialogs import GetImageHandlers
 from gui_core.dialogs import GetImageHandlers
 from mapwin.base import MapWindowProperties
 from mapwin.base import MapWindowProperties
-from core import globalvar
 from core.render import Map
 from core.render import Map
 from mapdisp import statusbar as sb
 from mapdisp import statusbar as sb
 from core.debug import Debug
 from core.debug import Debug
@@ -170,8 +169,7 @@ class SwipeMapFrame(DoubleMapFrame):
 
 
         # create statusbar and its manager
         # create statusbar and its manager
         statusbar = self.CreateStatusBar(number=4, style=0)
         statusbar = self.CreateStatusBar(number=4, style=0)
-        if globalvar.wxPython3:
-            statusbar.SetMinHeight(24)
+        statusbar.SetMinHeight(24)
         statusbar.SetStatusWidths([-5, -2, -1, -1])
         statusbar.SetStatusWidths([-5, -2, -1, -1])
         self.statusbarManager = sb.SbManager(
         self.statusbarManager = sb.SbManager(
             mapframe=self, statusbar=statusbar)
             mapframe=self, statusbar=statusbar)

+ 1 - 3
scripts/d.rast.edit/d.rast.edit.py

@@ -80,10 +80,8 @@ import atexit
 import grass.script as grass
 import grass.script as grass
 
 
 try:
 try:
-    import wxversion
-    wxversion.select(['3.0', '2.8', '2.6'])
     import wx
     import wx
-except Exception:
+except ImportError:
     # ensure that --help, --interface-description etc work even without wx
     # ensure that --help, --interface-description etc work even without wx
     if __name__ == "__main__":
     if __name__ == "__main__":
         if len(sys.argv) == 2:
         if len(sys.argv) == 2:

+ 0 - 2
scripts/wxpyimgview/wxpyimgview_gui.py

@@ -42,8 +42,6 @@ import numpy
 import time
 import time
 import signal
 import signal
 
 
-import wxversion
-wxversion.select('2.8')
 import wx
 import wx