Skip to content

Commit

Permalink
wxGUI: Check min required wx version when starting GUI (#2990)
Browse files Browse the repository at this point in the history
Co-authored-by: Anna Petrasova <kratochanna@gmail.com>
  • Loading branch information
landam and petrasovaa authored Jun 7, 2023
1 parent 88d6caf commit d10351c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
8 changes: 5 additions & 3 deletions gui/wxpython/core/globalvar.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ def CheckWxPhoenix():


def CheckWxVersion(version):
"""Check wx version"""
ver = wx.__version__
parsed_version = parse_version_string(ver)
"""Check wx version.
:return: True if current wx version is greater or equal than
specifed version otherwise False
"""
parsed_version = parse_version_string(wx.__version__)
if parsed_version < version:
return False

Expand Down
28 changes: 23 additions & 5 deletions gui/wxpython/wxgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# i18n is taken care of in the grass library code.
# So we need to import it before any of the GUI code.
from grass.exceptions import Usage
from grass.script.core import set_raise_on_error
from grass.script.core import set_raise_on_error, warning, error

from core import globalvar
from core.utils import registerPid, unregisterPid
Expand Down Expand Up @@ -91,10 +91,28 @@ def show_main_gui():
from main_window.frame import GMFrame
else:
from lmgr.frame import GMFrame

mainframe = GMFrame(parent=None, id=wx.ID_ANY, workspace=self.workspaceFile)
mainframe.Show()
self.SetTopWindow(mainframe)
try:
mainframe = GMFrame(
parent=None, id=wx.ID_ANY, workspace=self.workspaceFile
)
except Exception as err:
min_required_wx_version = [4, 2, 0]
if not globalvar.CheckWxVersion(min_required_wx_version):
error(err)
warning(
_(
"Current version of wxPython {} is lower than "
"minimum required version {}".format(
wx.__version__,
".".join(map(str, min_required_wx_version)),
)
)
)
else:
raise
else:
mainframe.Show()
self.SetTopWindow(mainframe)

wx.CallAfter(show_main_gui)

Expand Down

0 comments on commit d10351c

Please sign in to comment.