Skip to content

Conversation

@bluedotblue
Copy link

Description

Within the GUI, creating new raster maps with a required output name does not prompt the user of invalid character use on running the module. This feature has been applied already when creating a new vector map, with the MapValidator class within widgets.py. It was asked to use this MapValidator class to handle raster output names similarly in forms.py.

This pull request addresses issue #5978.

How has this been tested?

I overwrote the installation forms.py with my version and ran the GUI to check visually.

@github-actions github-actions bot added GUI wxGUI related Python Related code is in Python labels Sep 30, 2025
@petrasovaa
Copy link
Contributor

Thank you! It looks like it's preventing the dialog from running even if the name is correct.

Looking back at the linked issue, I would go with a different approach more consistent with the current usage of validators in the tool dialogs, e.g. see how r.surf.fractal dialog deals with entering some letters instead of numbers in the dimension parameter - it will highlight the field.

For that you need a slightly different validator, something like this would work (in gui_core/widgets.py):

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

    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()

and then you just add it to

https://github.com/OSGeo/grass/blob/main/gui/wxpython/gui_core/forms.py#L1511

petrasovaa
petrasovaa previously approved these changes Oct 24, 2025
Copy link
Contributor

@petrasovaa petrasovaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I changed it little bit to make it work.

@bluedotblue
Copy link
Author

bluedotblue commented Oct 24, 2025

Thank you @petrasovaa .. while you are here! Do you mind telling me some good documentation or just direct advice of how your grass suite of github actions work? And how you guys want python pull requests to be tested generally? Thank you for your help!

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@petrasovaa
Copy link
Contributor

Thank you @petrasovaa .. while you are here! Do you mind telling me some good documentation or just direct advice of how your grass suite of github actions work? And how you guys want python pull requests to be tested generally? Thank you for your help!

The actions run on all PRs, for new contributors we need to approve them (github policy). They test compilation, run tests (typically on tools, libraries), check formatting. Using pre-commit is recommended to get the formatting right (https://github.com/OSGeo/grass/blob/main/doc/development/style_guide.md#using-pre-commit).
In this case, we don't have any automated tests for GUI unfortunately, so it's expected that you test that particular feature.

That was just a brief answer, so let me know if you have more questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GUI wxGUI related Python Related code is in Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants