in reply to Perl Tk Forgetting a Widget
#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = MainWindow->new; my $mainFrame = $mw->Frame()->pack(-side=>'top'); my $tx; # reuse global to prevent memory gains rebuild(); #setup first use # script is called, runs, outputs to Scrolled above, user # chooses new option and sub clear() is called: my $button = $mw->Button(-text=> 'Clear', -command => \&clear )->pack(); my $button1 = $mw->Button(-text=> 'Rebuild', -command => \&rebuild )->pack(); MainLoop; sub clear{ #$mainFrame ->destroy(); # don't, causes screen jitter $tx->packForget; # $tx ->pack('forget'); #wrong usage #clean out a top level # my @w = $tl->packSlaves; # foreach (@w) { $_->packForget; } } sub rebuild{ $tx = $mainFrame->Scrolled(qw/Text -font normal -width 73 -height 15 -wrap word -scrollbars e/); $tx->pack; tie *STDOUT, 'Tk::Text', $tx; print "foobar!".time."\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl Tk Forgetting a Widget
by keszler (Priest) on Oct 15, 2011 at 15:28 UTC | |
by zentara (Cardinal) on Oct 16, 2011 at 13:39 UTC | |
by keszler (Priest) on Oct 17, 2011 at 04:23 UTC |