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]/},
In reply to Entry widget, default value and validatecommand by Real Perl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |