7 Einträge, 1 Seite |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::Tree; my $mw = tkinit; my $tree = $mw->Tree( -browsecmd => \&change )->pack; my $frame = $mw->Frame->pack; my %labels = ( test => $frame->Label( -text => 'test' ), hallo => $frame->Label( -text => 'hallo' ), ); for my $key ( keys %labels ){ $tree->add( $key , -text => $key ); } MainLoop; sub change{ my $item = shift; $_->packForget for $frame->children; $labels{$item}->pack; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::Tree; use Tk::Table; use Tk::Label; use Tk::Entry; my $mw = tkinit; my $tree = $mw->Tree( -browsecmd => \&change )->pack; my $table = $mw->Table->pack; my %labels = ( test => sub { my $wdgt = shift; return [$wdgt->Label( -text => 'test' ), $wdgt->Entry()] }, hallo => sub { my $wdgt = shift; return [$wdgt->Label( -text => 'hello world' ), $wdgt->Entry()] }, ); for my $key ( keys %labels ){ $tree->add( $key , -text => $key ); } MainLoop; sub change{ my $item = shift; $table->clear; my $widgets = $labels{$item}->($table); $table->put(0,$_, $widgets->[$_]) for 0..$#$widgets; # $labels{$item}->pack; }
7 Einträge, 1 Seite |