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

  • Home
  • SEARCH
  • 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 9169993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:57:19+00:00 2026-06-17T15:57:19+00:00

I have created a simple app which uses bare TextCtrl widgets with wxFILTER_NUMERIC in

  • 0

I have created a simple app which uses bare TextCtrl widgets with wxFILTER_NUMERIC in order to accept only numerical values (see code below).

I want the values to have a fixed display precision irrespective of how user inputs them (e.g. will always show 17.0000 in case of 17.0 or 17.000000 values being specified). I found that in wxPython there is an option to use a derived NumCtrl widget (http://wxpython.org/docs/api/wx.lib.masked.numctrl-module.html) which does the job but I can’t find it in the basic wxWidgets libraries.

So, is there a ready solution for this available somewhere which I simply cannot find or do I have to write a function which will change the format of the number manually once it has been inserted (handling EVT_TEXT and EVT_TEXT_ENTER events and modifying the input string)?

What I have so far:

Event table

BEGIN_EVENT_TABLE(MyFrame, wxFrame) 
    EVT_MENU(ID_Quit, MyFrame::OnQuit)
    EVT_MENU(ID_About, MyFrame::OnAbout)
    EVT_TEXT(ID_textBox, MyFrame::ValueChanged)
    EVT_TEXT_ENTER(ID_textBox, MyFrame::ValueChanged)
END_EVENT_TABLE()

Implementation of the text box inside MyFrame

wxPanel *panel = new wxPanel(this, -1);

    _textBox1 = new wxTextCtrl(panel,
         ID_textBox, 
         "0.0000", 
         wxPoint(100, 100), 
         wxSize(80,20),
         wxTE_PROCESS_ENTER,
         wxTextValidator(wxFILTER_NUMERIC,&_myValue),
         wxTextCtrlNameStr); 

Handling function

void MyFrame::ValueChanged(wxCommandEvent& WXUNUSED(event))
{
    // modify the string or do something clever
}

SOLUTION ADOPTED
Thanks to the answer the problem has been resolved. Here’s what I went with:

`

wxFloatingPointValidator<double> _val(2,&_myValue,wxNUM_VAL_ZERO_AS_BLANK);
    _val.SetRange(0.,100.);     // set allowable range

_textBox1 = new wxTextCtrl(panel,   // create a textCtrl
     ID_textBox, 
     "0.0000", 
     wxPoint(100, 30), 
     wxSize(80,20),
     wxTE_PROCESS_ENTER,
     _val,          // associate the text box with the desired validator
     wxTextCtrlNameStr); 

`

  • 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-06-17T15:57:20+00:00Added an answer on June 17, 2026 at 3:57 pm

    See wxFloatingPointValidator available in wxWidgets 2.9.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a simple app which shows a Google Map. I am testing
I'm have a simple rails app which uses mongoid. I have a parent document
i have created a simple web app which contains recaptcha authentication. however, i feel
I have a very simple asp.net mvc web app which uses castle active record,
I have managed to create a simple app which deletes (bypassing the recycle bin)
I have created very simple app with persistence context (hibernate as provider) to read
I have created a simple web app/form using google app engine. the site is
I have created a small and simple android app. I tried installing it on
I am using core data in my iPhone app. I have created a simple
I have created a simple map app that shows the local garage sales in

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.