954,541 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Text entered in a grid cell should be numeric

Hi All,

I have created a grid and want to implement the following idea:
The user should be able to enter only numeric values in any of the cells in that grid.

I could not get any property of the cell which can check for the entered data.

Please guide as for achieving this.

Thanks,
Dinil

dinilkarun
Posting Whiz in Training
206 posts since Feb 2008
Reputation Points: 18
Solved Threads: 0
 

I'm not entirely sure what you mean by a 'grid', but if you only want to accept numeric input, you can use a function like this to return it:

def getNum():
    while True:
        n = raw_input('Enter a number:')
        try:
            n = float(n)  # or int(n) if you want an integer
            return n
        except:
            print 'Enter a number!'


As for the second part of your question, I'm not fully sure what that 'grid' is, so can you elaborate on it or show some code please? Thanks.

shadwickman
Posting Pro in Training
497 posts since Jul 2007
Reputation Points: 186
Solved Threads: 77
 

Hi All,

I have created a grid and want to implement the following idea: The user should be able to enter only numeric values in any of the cells in that grid.

I could not get any property of the cell which can check for the entered data.

Please guide as for achieving this.

Thanks, Dinil

Look, dinilkarun. This is not the first time you have provided to little information. If you want answers that help you really need to put in the effort. What is this grid? Is it in wxPython, Tkinker, pyQT or something? Cause unless we know that we cant do anything.

Try harder and you'll find it pays off in better answers

Paul Thompson
Veteran Poster
1,119 posts since May 2008
Reputation Points: 264
Solved Threads: 183
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You