Hi Vadim and thank you very much!
The demo worked prety well, except it did not scroll the text so I could see the end. It looked like you were trying to optimise that and only move it when necessary. I had better results just calling see('end') each time.

Regards,
Jason

Once again, a full working program.


use Tcl::Tk;

sub Tcl::Tk::Widget::Text::TIEHANDLE {
   my ($class,$obj) = @_;
   return $obj;
}

sub Tcl::Tk::Widget::Text::PRINT {
   my $w = shift;

   # Loop over all input strings
   while (@_){
   $w->insert('end',shift);
   }
   # Make sure we can see this text
   $w->see('end');
}

sub Tcl::Tk::Widget::Text::PRINTF {
   my $w = shift;
   $w->PRINT(sprintf(shift,@_));
}


my $int = new Tcl::Tk;
my $mw = $int->mainwindow;

my $text = $mw->Text->pack;
my $button = $mw->Button->pack;
$button->configure(-text => "Tickle me", -command => sub {print "Whoaaaa Haaa Haaa! " . $count ++ . "\n";});

tie *STDOUT, ref $text, $text;

print "Did you know I was ticklish?\n";


$int->MainLoop;

Reply via email to