Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

does anyone know how to make a tk entry widget stop taking any input once a given number of characters have been typed into it?
  • Comment on limit number of characters in entry widget

Replies are listed 'Best First'.
Re: limit number of characters in entry widget
by thundergnat (Deacon) on Jun 17, 2005 at 13:07 UTC
    my $length = 6; $widget->Entry( -validate => 'key', -vcmd => sub{ return 1 if (length($_[0]) <= $length); return 0; } );
      thanks
Re: limit number of characters in entry widget
by davidrw (Prior) on Jun 17, 2005 at 13:06 UTC
    Not directly that i know of, but looking at the docs for Tk::Entry you can can add a validation sub that checks the length and it could just crop the value.
      i see $box = $mw->Entry(-validate=>'key', -validateCommand=>'\&myLengthCroppingSub', ...other options)