|
Re: Verifying Entry inputs: msg#00138gnome.gtk+.python
On Fri, 25 Feb 2005 09:11:56 +0100, Hans-Joachim Widmaier <hjwidmaier@xxxxxx> wrote: > Hi all, > > I'd like to have Entry widgets that allow only numbers (float) as inputs, and > only > in a certain range. May be this function will help you: def entry_float(entry, new_text, new_text_length, position): """Connect insert-text signal to this function to validate floating type""" lst_old_string = list(entry.get_chars(0, -1)) _pos = entry.get_position() lst_new_string = lst_old_string.insert(_pos, new_text) _string = "".join(lst_old_string) _hid = entry.get_data('handlerid') entry.handler_block(_hid) try: _val = float(_string) _pos = entry.insert_text(new_text, _pos) except StandardError, e: pass entry.handler_unblock(_hid) gtk.idle_add(lambda t: t.set_position(t.get_position()+1), entry) entry.stop_emission("insert-text") pass Usage:- self.etrInfo = gtk.Entry() handlerid = self.etrInfo.connect("insert_text", entry_float) self.etrInfo.set_data('handlerid', handlerid) Regards, Baiju M _______________________________________________ pygtk mailing list pygtk@xxxxxxxxxx http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/ |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: licensing question: 00138, Sorin C. |
|---|---|
| Next by Date: | Re: Verifying Entry inputs: 00138, John Gill |
| Previous by Thread: | Verifying Entry inputsi: 00138, Hans-Joachim Widmaier |
| Next by Thread: | Re: Verifying Entry inputs: 00138, John Gill |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |