I need help implementing some form of validation into my application. I have a wx.TextCtrl control which accepts a valid URL from the user. I would like to validate the URL before it is passed on to the Requests library and to bs4 library further on.
So, what's the way to do it? I would like to avoid any regexes if possible.
My current implementation is the following...
"""
The module validatortest is intended for validating a URL given by the
user in a text control window/widget.
"""
import wx
class ValidateURL(wx.Validator):
    """
    Create the validator object.
    """
    def __init__(self):
        """
        Initialize the validator.
        """
        super().__init__()
    def Clone(self):
        """
        Clone the validator.
        """
        return ValidateURL()
    def Validate(self, window):
        """
        Do URL validation.
        """
        pass
        # First implementation
        #
        # textField = self.GetWindow()
        # textFieldValue = textField.GetValue()
        # Alternative?
        #
        # textField = window.Get()
        # textFieldValue = textField.GetValue()
        # Perhaps even this?
        #
        # textFieldValue = window.GetValue()
        # import validators
        # try:
        #     if validators.url(textFieldValue):
        #         return True
        # except ValidationFailure:
        #     wx.MessageBox(caption="Validation Failure",
        #                   message="Please input a valid URL address form.",
        #                   style=wx.OK | wx.ICON_ERROR)
        #     return False
    def TransferToWindow(self):
        """
        This method is called when the value associated with the
        validator must be transferred to the window/widget.
        """
        return True
    def TransferFromWindow(self):
        """
        This method is called when the value in the window/widget must
        be transferred to the validator.
        """
        return True
