1: Check for data in Text widget -there are other ways, but I think this is the most efficient.
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;
In your sub it looks like you want something like:
if ($text->index('end - 1c') > 1) { ... }
As for 2, It looks to me like "right" and "left" set margins -- they are not intended for wrapping text. You probably want the break option, which can support break_wrap, break_at, and break_TeX. It looks like break_wrap might be what you're looking for. Also check the Text::Reform module (which Autotext uses) for more info
RobIn reply to Re: Checking Tk::Text, problems with Text::Autoformat and finally Text::Wrap
by rcseege
in thread Checking Tk::Text, problems with Text::Autoformat and finally Text::Wrap
by BubbaMonk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |