From Code to Community: Sponsoring The Perl and Raku Conference 2025 Learn more

NAME

Tk::TextDialog - Dialog widget with text entry.

SYNOPSIS

use Tk;
$d = $w -> TextDialog ( -font => [-family=>'helvetica',-size=>12, -weight=>'normal'],
-title => 'Text Entry',
-textlabel => 'Please enter your text:');
$d -> WaitForInput;
$d -> destroy;

DESCRIPTION

The -font option defaults to helvetica 12
The -textlabel option prints the text of its argument in label above
the text entry box.
After WaitForInput is called, clicking on the 'Accept' button closes the dialog
and returns the text in the entry box.
The WaitForInput method does not destroy the dialog window. Instead
WaitForInput unmaps the dialog box from the display. To de-allocate
the widget, you must explicitly call $w -> destroy or $w -> DESTROY.
Refer to the Tk::options man page for a description of options
common to all Perl/Tk widgets.
Example:
use Tk;
my $w = new MainWindow;
my $b = $w -> Button (-text => 'Dialog',
-command => sub{&show_dialog($w)}) -> pack;
sub show_dialog {
my ($w) = @_;
my $e;
if (not defined $e) {
$e = $w -> TextDialog (-title => 'Enter Text', -height=>5, -width=>20); # Height and width of the text box
$e -> configure (-textlabel => 'Please enter your text:');
}
my $resp = $e -> WaitForInput;
print "$resp\n";
$e -> configure (-textlabel => '');
my $resp = $e -> WaitForInput;
print "$resp\n";
return $resp;
}
MainLoop;

VERSION

$Revision: 0.0.1 $
Licensed for free distribution under the terms of the
Perl Artistic License.
Written by Mark Daglish ,mark-daglish@blueyonder.co.uk>, but heavily copied from the EntryDialog module written
by Robert Allan Kiesling <rkiesling@earthlink.net> and Dave Scheck <cds033@email.mot.com>.