[Tutor] Query about using Pmw entry widget...
John Fouhy
john at fouhy.net
Sun Jan 7 10:58:27 CET 2007
On 07/01/07, Alan Gauld <alan.gauld at btinternet.com> wrote:
> I don;t have PMW installed. I tend to use Tix now that its part
> of standard Python. However Grayson says this:
Does Tix work with py2exe? That's why I gave up on it, a while ago..
> So it seems you need
>
> def numeric(val):
> try: float(val)
> except ValueError: return Pmw.ERROR
> else: return Pmw.OK
>
> timeinterval = Pmw.EntryField(.....validate=numeric)
>From memory, you have to do something like
"validate={'validator':numeric}" if you're not using one of the
built-in validators.
(which Asrarahmed would need to do, since he wants to restrict the
range of numbers available)
Also, this will not work quite right; you need something like:
def numeric(val):
try:
float(val)
except ValueError:
if val == '':
return Pmw.PARTIAL
return Pmw.ERROR
return Pmw.OK
--
John.
More information about the Tutor
mailing list