Text entered in a grid cell should be numeric

Reply

Join Date: Feb 2008
Posts: 198
Reputation: dinilkarun is an unknown quantity at this point 
Solved Threads: 0
dinilkarun dinilkarun is offline Offline
Junior Poster

Text entered in a grid cell should be numeric

 
0
  #1
May 11th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 489
Reputation: shadwickman will become famous soon enough shadwickman will become famous soon enough 
Solved Threads: 76
shadwickman's Avatar
shadwickman shadwickman is offline Offline
Posting Pro in Training

Re: Text entered in a grid cell should be numeric

 
0
  #2
May 11th, 2009
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:

  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.
"Two good old boys in a fire-apple red convertible. Stoned. Ripped. Twisted. Good people."
- Hunter S. Thompson

my photography
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 899
Reputation: Paul Thompson has a spectacular aura about Paul Thompson has a spectacular aura about 
Solved Threads: 145
Sponsor
Paul Thompson's Avatar
Paul Thompson Paul Thompson is offline Offline
previously paulthom12345

Re: Text entered in a grid cell should be numeric

 
0
  #3
May 11th, 2009
Originally Posted by dinilkarun View 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
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
Make it idiot proof and someone will make a better idiot.
Check out my Site | and join us on IRC | Python Specific IRC
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC