Skip Menu |

This queue is for tickets about the Tk CPAN distribution.

Report information
The Basics
Id: 45818
Status: resolved
Priority: 0/
Queue: Tk

People
Owner: Nobody in particular
Requestors: DJIBEL [...] cpan.org
Cc: slaven [...] rezic.de
AdminCc:

Bug Information
Severity: Critical
Broken in:
  • 804.028
  • 804.028_500
  • 804.028_501
Fixed in: 804.029_500



CC: slaven [...] rezic.de
Subject: [Update] Tie Stdout, Tk::Text and syswrite
Dear, Example : #!/usr/bin/perl use warnings; use strict; use Tk; my $mw = MainWindow->new; my $Scrolled = $mw->Scrolled( "Text", -height => 10, -wrap => "none", -relief => "solid", -background => "white", -scrollbars => "osoe", )->pack(qw/ -side bottom -pady 15 -padx 15 -fill both -expand 1 /); tie *STDOUT, $Scrolled, $Scrolled->Subwidget('scrolled'); for ( 1 .. 15 ) { print "Hello Text World!\n"; my $toto = sprintf( "%.3f", 123.456789 ); syswrite( *STDOUT, "$toto\n",-3 ); } print "End Tie\n"; untie *STDOUT; print "After Tie\n"; MainLoop; 1- Small update in Tk::Text. tie *STDOUT, ref $text, $text; work only if we use print and printf method. It's possible to add method sprintf and syswrite ? Else we have this error message : Can't locate auto/Tk/Text/WRITE.al in @INC (@INC contains: C:/Perl/site/lib C:/Perl/lib .) at C\test.pl line 23 That is a Perl code to resolv this problem, you can add it in Text.pm sub WRITE { my ($w, $scalar, $length, $offset) = @_; unless ( defined $length ) { $length = length $scalar; } unless ( defined $offset ) { $offset = 0; } $w->PRINT( substr($scalar,$offset,$length) ); } I have test and it work well : tie *STDOUT, 'Tk::Text', $Scrolled->Subwidget('scrolled'); or tie *STDOUT, $Scrolled, $Scrolled->Subwidget('scrolled'); 2- Update in Tk::Text POD Can you add that this in section TIED INTERFACE To Tie in text scrolled widget, don't forget to use Subwidget method. tie *STDOUT, 'Tk::Text', $Scrolled->Subwidget('scrolled'); 3- Bug untie If I want to untie, It's work but I have an error message : untie attempted while 13 inner references still exist at ... Best Regards Djibril Ousmanou
On Thu May 07 09:33:38 2009, DJIBEL wrote: Show quoted text
> Dear, > > Example : > > #!/usr/bin/perl > use warnings; > use strict; > use Tk; > > my $mw = MainWindow->new; > > my $Scrolled = $mw->Scrolled( > "Text", > -height => 10, > -wrap => "none", > -relief => "solid", > -background => "white", > -scrollbars => "osoe", > )->pack(qw/ -side bottom -pady 15 -padx 15 -fill both -expand 1 /); > > tie *STDOUT, $Scrolled, $Scrolled->Subwidget('scrolled'); > > for ( 1 .. 15 ) { > print "Hello Text World!\n"; > my $toto = sprintf( "%.3f", 123.456789 ); > syswrite( *STDOUT, "$toto\n",-3 ); > } > print "End Tie\n"; > untie *STDOUT; > print "After Tie\n"; > MainLoop; > > 1- Small update in Tk::Text. > > tie *STDOUT, ref $text, $text; work only if we use print and printf
method. Show quoted text
> > It's possible to add method sprintf and syswrite ? Else we have this > error message : > Can't locate auto/Tk/Text/WRITE.al in @INC (@INC contains: > C:/Perl/site/lib C:/Perl/lib .) at C\test.pl line 23 > > That is a Perl code to resolv this problem, you can add it in Text.pm > > sub WRITE { > my ($w, $scalar, $length, $offset) = @_; > > unless ( defined $length ) { $length = length $scalar; } > unless ( defined $offset ) { $offset = 0; } > $w->PRINT( substr($scalar,$offset,$length) ); > } > > I have test and it work well : > tie *STDOUT, 'Tk::Text', $Scrolled->Subwidget('scrolled'); > or > tie *STDOUT, $Scrolled, $Scrolled->Subwidget('scrolled'); > > > 2- Update in Tk::Text POD > > Can you add that this in section TIED INTERFACE > > To Tie in text scrolled widget, don't forget to use Subwidget method. > tie *STDOUT, 'Tk::Text', $Scrolled->Subwidget('scrolled'); > > 3- Bug untie > If I want to untie, It's work but I have an error message : > untie attempted while 13 inner references still exist at ... >
Thanks, 1 and 2 are now in the Perl/Tk subversion repository as r13799. For nr 3 I currently have no idea how to fix it. The only observation is that the number of inner references go down if untie() comes after $text->destroy. Regards, Slaven