Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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
7 changes: 6 additions & 1 deletion gui/wxpython/gui_core/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
FormListbook,
FormNotebook,
PlacementValidator,
MapNameValidator,
)
from core.giface import Notification, StandaloneGrassInterface
from gui_core.widgets import LayersList
Expand Down Expand Up @@ -1509,6 +1510,9 @@ def __init__(self, parent, giface, task, id=wx.ID_ANY, frame=None, *args, **kwar
selection = gselect.Select(
parent=which_panel,
id=wx.ID_ANY,
validator=MapNameValidator()
if p.get("age") == "new"
else wx.DefaultValidator,
size=globalvar.DIALOG_GSELECT_SIZE,
type=elem,
multiple=multiple,
Expand Down Expand Up @@ -3350,7 +3354,8 @@ def OnInit(self):
"gisprompt": False,
"multiple": "yes",
# values must be an array of strings
"values": utils.str2rgb.keys() + list(map(str, utils.str2rgb.values())),
"values": list(utils.str2rgb.keys())
+ list(map(str, utils.str2rgb.values())),
"key_desc": ["value"],
"values_desc": [],
},
Expand Down
26 changes: 26 additions & 0 deletions gui/wxpython/gui_core/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- widgets::EmailValidator
- widgets::TimeISOValidator
- widgets::MapValidator
- widgets::MapNameValidator
- widgets::NTCValidator
- widgets::SimpleValidator
- widgets::GenericValidator
Expand Down Expand Up @@ -889,11 +890,36 @@
GenericValidator.__init__(self, grass.legal_name, _mapNameValidationFailed)


class MapNameValidator(BaseValidator):
"""Validator for map name input

See G_legal_filename()
"""

def __init__(self):
BaseValidator.__init__(self)

def _validate(self, win):
"""Validate input"""
text = win.GetValue()
if text:
if not grass.legal_name(text):
self._notvalid()
return False

self._valid()
return True

def Clone(self):
"""Clone validator"""
return MapNameValidator()

class GenericMultiValidator(Validator):

Check failure on line 918 in gui/wxpython/gui_core/widgets.py

View workflow job for this annotation

GitHub Actions / Python Code Quality Checks (ubuntu-24.04)

Ruff (E302)

gui/wxpython/gui_core/widgets.py:918:1: E302 Expected 2 blank lines, found 1
"""This validator checks conditions and calls callbacks
in case the condition is not fulfilled.
"""

Check failure on line 922 in gui/wxpython/gui_core/widgets.py

View workflow job for this annotation

GitHub Actions / Python Code Quality Checks (ubuntu-24.04)

Ruff (D211)

gui/wxpython/gui_core/widgets.py:920:5: D211 No blank lines allowed before class docstring
def __init__(self, checks):
"""Standard constructor.

Expand Down
Loading