Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 607855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:24:10+00:00 2026-05-13T17:24:10+00:00

I need to validate the textboxes with wx.Textvalidator. Any please help me to do

  • 0

I need to validate the textboxes with wx.Textvalidator.
Any please help me to do this?

How can i use wx.FILTER_ALPHA with validators and if the user is giving a wrong input how can i give them a message?

i need to validate all the inputs when clicking on the save button?

can any one provide me a sample code for this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T17:24:11+00:00Added an answer on May 13, 2026 at 5:24 pm

    This is a feature of wxWidgets, and is not implemented in wxPython.

    http://www.wxpython.org/docs/api/wx.TextValidator-class.html – not found

    while:

    http://docs.wxwidgets.org/trunk/classwx_text_validator.html
    http://docs.wxwidgets.org/stable/wx_wxtextvalidator.html

    There is a demo of the Validators in the wxPython demo:

    import wx
    
    class TextObjectValidator(wx.PyValidator):
         """ This validator is used to ensure that the user has entered something
             into the text object editor dialog's text field.
         """
         def __init__(self):
             """ Standard constructor.
             """
             wx.PyValidator.__init__(self)
    
    
    
         def Clone(self):
             """ Standard cloner.
    
                 Note that every validator must implement the Clone() method.
             """
             return TextObjectValidator()
    
    
         def Validate(self, win):
             """ Validate the contents of the given text control.
             """
             textCtrl = self.GetWindow()
             text = textCtrl.GetValue()
    
             if len(text) == 0:
                 wx.MessageBox("A text object must contain some text!", "Error")
                 textCtrl.SetBackgroundColour("pink")
                 textCtrl.SetFocus()
                 textCtrl.Refresh()
                 return False
             else:
                 textCtrl.SetBackgroundColour(
                     wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW))
                 textCtrl.Refresh()
                 return True
    
    
         def TransferToWindow(self):
             """ Transfer data from validator to window.
    
                 The default implementation returns False, indicating that an error
                 occurred.  We simply return True, as we don't do any data transfer.
             """
             return True # Prevent wxDialog from complaining.
    
    
         def TransferFromWindow(self):
             """ Transfer data from window to validator.
    
                 The default implementation returns False, indicating that an error
                 occurred.  We simply return True, as we don't do any data transfer.
             """
             return True # Prevent wxDialog from complaining.
    
    #----------------------------------------------------------------------
    
    class TestValidateDialog(wx.Dialog):
        def __init__(self, parent):
            wx.Dialog.__init__(self, parent, -1, "Validated Dialog")
    
            self.SetAutoLayout(True)
            VSPACE = 10
    
            fgs = wx.FlexGridSizer(0, 2)
    
            fgs.Add((1,1));
            fgs.Add(wx.StaticText(self, -1,
                                 "These controls must have text entered into them.  Each\n"
                                 "one has a validator that is checked when the Okay\n"
                                 "button is clicked."))
    
            fgs.Add((1,VSPACE)); fgs.Add((1,VSPACE))
    
            label = wx.StaticText(self, -1, "First: ")
            fgs.Add(label, 0, wx.ALIGN_RIGHT|wx.CENTER)
    
            fgs.Add(wx.TextCtrl(self, -1, "", validator = TextObjectValidator()))
    
            fgs.Add((1,VSPACE)); fgs.Add((1,VSPACE))
    
            label = wx.StaticText(self, -1, "Second: ")
            fgs.Add(label, 0, wx.ALIGN_RIGHT|wx.CENTER)
            fgs.Add(wx.TextCtrl(self, -1, "", validator = TextObjectValidator()))
    
    
            buttons = wx.StdDialogButtonSizer() #wx.BoxSizer(wx.HORIZONTAL)
            b = wx.Button(self, wx.ID_OK, "OK")
            b.SetDefault()
            buttons.AddButton(b)
            buttons.AddButton(wx.Button(self, wx.ID_CANCEL, "Cancel"))
            buttons.Realize()
    
            border = wx.BoxSizer(wx.VERTICAL)
            border.Add(fgs, 1, wx.GROW|wx.ALL, 25)
            border.Add(buttons)
            self.SetSizer(border)
            border.Fit(self)
            self.Layout()
    
    
    
    app = wx.App(redirect=False)
    f = wx.Frame(parent=None)
    f.Show()
    dlg = TestValidateDialog(f)
    dlg.ShowModal()
    dlg.Destroy()
    
    app.MainLoop()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 304k
  • Answers 304k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I managed to fine tune my approach so that it's… May 13, 2026 at 8:55 pm
  • Editorial Team
    Editorial Team added an answer There are a few ways that you can facilitate user… May 13, 2026 at 8:55 pm
  • Editorial Team
    Editorial Team added an answer (Tangential to your question but related) NSNumber isn't intended to… May 13, 2026 at 8:55 pm

Related Questions

This seems like it should have a simple solution but I can't seem to
I have a custom validator that points to a Client side script to validate
I have a control which extends the DataGridView control. I am overriding the ProcessDialyKey
I have a C# form with multiple text boxes. Before proceeding I need to
We need to stop copy paste of few characters like '<' or '>' or

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.