in reply to Checking Tk::Text, problems with Text::Autoformat and finally Text::Wrap

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

Rob

Replies are listed 'Best First'.
Re^2: Checking Tk::Text, problems with Text::Autoformat and finally Text::Wrap
by BubbaMonk (Sexton) on Oct 20, 2006 at 05:52 UTC
    Hey, Rob! Thanks for the answers; much appreciated! So much so I'm going to make three more logins just so I can upvote you more! I'm thinking paco, pAco and pacO....

    I haven't looked yet, but I'd speculate that break probably won't pull off what I want, either. I'm guessing it would treat the >'s as regular characters dumping them in the middle of lines. Maybe I'll just have to write a new module and they can shove it into Perl 6. Oh, no, working under a deadline! I've got about what, six years to finish it in time? ;)

    Thanks again. BM