in reply to Re: read Tk Text Widget when content changes
in thread read Tk Text Widget when content changes
Thank you very much!
After playing a bit with the tips and examples provided I came up with this solution which seems to suit perfectly
use warnings; use strict; use Tk; my $mw = MainWindow->new(); my $tx = $mw->Text()->pack(); $tx->bind( '<<Modified>>' => \&readTextWidget); my $CursorPosition="1.0"; MainLoop; sub readTextWidget{ if ($tx->editModified()) { my @Text=$tx->dump($CursorPosition,'end'); my $TextChunk = $Text[1]; $CursorPosition= $Text[5]; my @words = split / /, $TextChunk ;#very basic tokenizer for t +he moment foreach my $word (@words) { print "$word\n"; } $tx->editModified(0); } }
|
|---|