1Tk::EntryCheck(3) User Contributed Perl Documentation Tk::EntryCheck(3)
2
3
4
6 Tk::EntryCheck - Interface to Tk::Entry for controlling its maximum
7 length and content in an easy way.
8
10 use Tk;
11 use Tk::EntryCheck;
12
13 my $mw = MainWindow->new();
14
15 my $entry = $mw->EntryCheck(
16
17 # some standard Entry-Options which are forwarded to Tk::Entry
18 -width => 20,
19
20 # and now the new options
21 -maxlength => 10, # accepts 10 chars at maximum for content
22 -pattern => qr/\d/, # accepts only \d, nothing else
23 )
24 ->pack();
25
26 MainLoop();
27
29 This module acts as a little wrapper around Tk::Entry and adds an easy
30 to use interface to -validate and -validatecommand for controlling
31 length and content of an entry widget.
32
33 It's provides the following additional features:
34
35 x) Set a maximum length to this entry with the parameter -maxlenght.
36 Gives a warning by carp if this is defined but not a positive integer.
37 If the content is added by changing a variable attached as
38 -textvariable, it also gives a warning with carp and denies the change.
39
40 x) Allow only certain characters inside this entry. You can submit it
41 as a regular expression in the parameter -pattern, e.g.
42
43 -pattern => qr/[A-Za-z0-9]/, # alphanumeric
44
45 -pattern = qr/\d/, # numbers only
46
47 -pattern = qr/[A-Z ]/, # capital characters and spaces
48
49 If the content is added by a variable attached to the widget as
50 -textvariable, it also gives a warning with carp and denies the change.
51
52 ATTENTION: this character class check is done for each character and
53 enhanced internally by *, so don't try to use something like -pattern =
54 qr(\d+)>, because that would result in \d+* and give an error.
55
56 ATTENTION: don't forget to specify an empty space if you need it...
57
58 If you want to overwrite the methods used for validation, you can do so
59 by just setting the original entry options -validate and/or
60 -validatecommand...
61
63 x) Perl-Version >= 5.005
64
65 x) Tk and Tk::Entry must be installed and running
66
68 Nothing. As there is no need for exports and as I hate namespace
69 pollution, I removed the Exporter...
70
72 See Tk::Entry for the other options, especially the options -validate
73 and -validatecommand
74
75 See Tk::FilterEntry which is similar.
76
77 Differences between Tk::EntryCheck and Tk::FilterEntry
78
79 x) FilterEntry doesn't deny adding invalid chars or strings which are
80 too long
81
82 x) EntryCheck just checks each char if it in a characterclass, whereas
83 FilterEntry checks the whole content with a regular expression, so it
84 is more helpful when checking for special formats
85
86 x) FilterEntry (v0.02) gives a warning if the field is empty
87
88 x) FilterEntry gives nice textcolors if the content of the textfield is
89 invalid; but that just works when the widget leaves the focus (V0.02)
90
91 See <http://www.fabiani.net/>: My Homepage (in German)
92
93 See <http://www.perl-community.de/>: German Perl Forum
94
96 Martin Fabiani (aka Strat), <martin@fabiani.net>
97
99 Copyright (C) 2004 by Martin Fabiani
100
101 This library is free software; you can redistribute it and/or modify it
102 under the same terms as Perl itself, either Perl version 5.8.3 or, at
103 your option, any later version of Perl 5 you may have available.
104
105
106
107perl v5.32.0 2020-07-28 Tk::EntryCheck(3)