Tk::EntryCheck(3)
π Tk::EntryCheck(3) β your Tk::Entry, but with boundaries and a glow-up π
π NAME π
Tk::EntryCheck β an interface to Tk::Entry for controlling its maximum length and content in an easy way. Thatβs the whole vibe. Periodt. π
β¨ SYNOPSIS β¨
use Tk;
use Tk::EntryCheck;
my $mw = MainWindow->new();
my $entry = $mw->EntryCheck(
# some standard Entry-Options which are forwarded to Tk::Entry
-width => 20,
# and now the new options
-maxlength => 10, # accepts 10 chars at maximum for content
-pattern => qr/\d/, # accepts only \d, nothing else
)
->pack();
MainLoop();
πΈ DESCRIPTION πΈ
Okay so this module is lowkey a little wrapper around Tk::Entry, and it adds an easy-to-use interface to -validate and -validatecommand for controlling the length and content of an entry widget. Itβs giving βentry widget but make it behave.β β¨
Itβs giving you these additional features:
-maxlenghtβ set a maximum length for this entry with this parameter. If itβs defined but is not a positive integer, it gives a warning bycarp. If the content is added by changing a variable attached as-textvariable, it also gives a warning withcarpand denies the change. π-patternβ allow only certain characters inside this entry. You can submit it as a regular expression in the parameter-pattern, e.g.
-pattern => qr/[A-Za-z0-9]/, # alphanumeric
-pattern = qr/\d/, # numbers only
-pattern = qr/[A-Z ]/, # capital characters and spaces
If the content is added by a variable attached to the widget as -textvariable, it also gives a warning with carp and denies the change.
β οΈ ATTENTION: this character class check is done for each character and enhanced internally by*, so don't try to use something like-pattern = qr(\d+)>, because that would result in\d+*and give an error. π
β οΈ ATTENTION: don't forget to specify an empty space if you need it... like, actually put the space in there, bestie.
If you want to overwrite the methods used for validation, you can do so by just setting the original entry options -validate and/or -validatecommand... π«Ά
π§Έ Dependencies π§Έ
- Perl-Version >= 5.005
TkandTk::Entrymust be installed and running
π« EXPORT π«
Nothing. As there is no need for exports and as I hate namespace pollution, I removed the Exporter... no cap, we keep it clean. π§Ό
π SEE ALSO π
See Tk::Entry for the other options, especially the options -validate and -validatecommand β thatβs where the rest of the lore lives. π
See Tk::FilterEntry which is similar.
π¦ Differences between Tk::EntryCheck and Tk::FilterEntry π¦
FilterEntrydoesn't deny adding invalid chars or strings which are too longEntryCheckjust checks each char if it in a characterclass, whereasFilterEntrychecks the whole content with a regular expression, so it is more helpful when checking for special formatsFilterEntry(v0.02) gives a warning if the field is emptyFilterEntrygives nice textcolors if the content of the textfield is invalid; but that just works when the widget leaves the focus (V0.02)
See http://www.fabiani.net/ β My Homepage (in German)
See http://www.perl-community.de/ β German Perl Forum
π AUTHOR π
Martin Fabiani (aka Strat), martin@fabiani.net
π COPYRIGHT AND LICENSE π
Copyright (C) 2004 by Martin Fabiani
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.3 or, at your option, any later version of Perl 5 you may have available.
Okay thatβs the whole page, bestie β source/version vibes: perl v5.32.1, dated 2024-09-24, and the manual is Tk::EntryCheck(3). Mwah πβ¨
π¦ where this page comes from
- epel 9: perl-Tk-EntryCheck 0.04-39.el9 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms