in reply to Perl/Tk code structure
What you are looking for is packForget and it's associate methods. You can pack a window with widgets, packforget all or some of the widgets so they are removed from the screen, reconfigure the widgets, then repack them. A simple example:
#!/usr/bin/perl use warnings; use strict; use Tk; my $top = new MainWindow; my @counts = ('a'..'z'); my %cbuttons; my $frame = $top->Frame()->pack(); setup_page(); $top->Button(-text => "packForget", -command => sub{ my @w = $frame->packSlaves; foreach (@w) { $_->packForget; } })->pack(); $top->Button(-text => "repack", -command => sub{ &setup_page })->pack(); $top->Button(-text => "Exit", -command => sub {exit})->pack; MainLoop; sub setup_page{ for (1..4){ my $text = shift @counts; $cbuttons{$_}{'cb'} = $frame->Checkbutton( -text => $text, -variable => \$cbuttons{$_}{'val'}, -command => \&SetState, )->pack; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl/Tk code structure
by elef (Friar) on Jan 11, 2012 at 09:47 UTC | |
by zentara (Cardinal) on Jan 11, 2012 at 10:42 UTC | |
by elef (Friar) on Jan 11, 2012 at 10:48 UTC | |
by zentara (Cardinal) on Jan 11, 2012 at 10:56 UTC |