Does anybody know how to create a text field using PyGTK that only accepts number. I am using Glade to build my UI.
Cheers,
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
I wouldn’t know about a way to do something like this by simple switching a settings, I guess you will need to handle this via signals, one way would be to connect to the
changedsignal and then filter out anything that’s not a number.Simple approach(untested but should work):
If you want formatted Numbers you could of course go more fancy with a regex or something else, to determine which characters should stay inside the entry.
EDIT
Since you may not want to create your Entry in Python I’m going to show you a simple way to “numbify” an existing one.