in reply to Indices and inserts in Tk::Text
This shows the empty text problem more clearly:my $but2 = $frame->Button(-text => "Replace in the end", -command => [\&replace,$text,'16.0', "end - 1c" ]) ->pack(-side => 'left');
#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = MainWindow->new; my $text = $mw->Text->pack; my $bFrame = $mw->Frame->pack(qw/-side bottom/); $bFrame->Button( -text => "Check Text", -command => sub { if ($text->index('end - 1c') == 1) { print "Text is empty\n"; } else { print "Text contains data\n"; } })->pack(qw/-side left/); $bFrame->Button( -text => "Clear Text", -command => sub { $text->delete("1.0", 'end'); })->pack(qw/-side left/); MainLoop;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Indices and inserts in Tk::Text
by jethro (Monsignor) on Nov 27, 2008 at 19:56 UTC | |
by zentara (Cardinal) on Nov 28, 2008 at 13:47 UTC |