Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wxGUI: Check min required wx version when starting GUI #2990

Merged
merged 3 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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