Real Perl has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
I would like to know if there is way for me to restrict my user from what he can enter in an entry widget, but at the same time have a default value in that widget as the application loads. The code below does not display the value in the entry widget:#!/usr/bin/perl -w use strict; use Tk; my $page2; my $w=0; my $wtf; my $wentry= 3; my $wcb; $page2 = MainWindow -> new(); $wcb = $page2 ->Checkbutton (-text=> '/W:', -variable=> \$w, -font=>"A +dobe 10")->pack; #$wcb->select(); $wtf = $page2 ->Entry (-textvariable=> \ $wentry, -width=>8, -validate=> 'key', -validatecommand=> sub{$_[1] =~/[0-9]/}, -invalidcommand=> sub{$page2->bell} )->pack; MainLoop;
However, if I comment out the
line, it works great. Thanks in advance for any idea about how I could have the best of both world. -- I would like to not have to check what crap the user can give me after the fact. Claire-validatecommand=> sub{$_[1] =~/[0-9]/},
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Entry widget, default value and validatecommand
by pg (Canon) on Aug 01, 2005 at 03:12 UTC | |
by Real Perl (Beadle) on Aug 01, 2005 at 05:03 UTC | |
by GrandFather (Saint) on Aug 01, 2005 at 05:12 UTC | |
|
Re: Entry widget, default value and validatecommand
by GrandFather (Saint) on Aug 01, 2005 at 02:23 UTC | |
|
Re: Entry widget, default value and validatecommand
by strat (Canon) on Aug 01, 2005 at 06:35 UTC |