943,907 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Unsolved
  • Views: 590
  • Python RSS
May 11th, 2009
0

Text entered in a grid cell should be numeric

Expand Post »
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
Similar Threads
Reputation Points: 18
Solved Threads: 0
Posting Whiz in Training
dinilkarun is offline Offline
206 posts
since Feb 2008
May 11th, 2009
0

Re: Text entered in a grid cell should be numeric

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:

python Syntax (Toggle Plain Text)
  1. def getNum():
  2. while True:
  3. n = raw_input('Enter a number:')
  4. try:
  5. n = float(n) # or int(n) if you want an integer
  6. return n
  7. except:
  8. 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.
Reputation Points: 186
Solved Threads: 77
Posting Pro in Training
shadwickman is offline Offline
495 posts
since Jul 2007
May 11th, 2009
0

Re: Text entered in a grid cell should be numeric

Click to Expand / Collapse  Quote originally posted by dinilkarun ...
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
Reputation Points: 264
Solved Threads: 183
Veteran Poster
Paul Thompson is offline Offline
1,095 posts
since May 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: Help needed: String to Dictionary conversion
Next Thread in Python Forum Timeline: Text entered in a grid cell should be numeric





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC