1 2 3 4 5 6 7 8 9 10 11 12 13 14
sub ToolEntry { my $self = shift; my %args = @_; my $m = delete $args{-tip} || ''; my $l = $self->{CONTAINER}->Entry(%args, -width => 5); push @{$self->{WIDGETS}} => $l; $self->_packWidget($l); $self->{BALLOON}->attach($b, -balloonmsg => $m) if $m; return $l; }
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 34 35 36
use Tk; use Tk::ToolBar; my $mw = new MainWindow; my $tb = $mw->ToolBar(qw/-movable 1 -side top -indicatorcolor blue/); $tb->ToolButton (-text => 'Button', -tip => 'tool tip', -command => sub { print "hi\n" }); $tb->ToolLabel (-text => 'A Label'); $tb->Label (-text => 'Another Label'); $tb->ToolLabEntry(-label => 'A LabEntry', -labelPack => [-side => "left", -anchor => "w"]); # erstelle einen extra frame: my $frame = $tb->Frame()->pack(-side => right); $frame->Entry(-width => 40)->pack; my $tb2 = $mw->ToolBar; $tb2->ToolButton(-image => 'navback22', -tip => 'back', -command => \&back); $tb2->ToolButton(-image => 'navforward22', -tip => 'forward', -command => \&forward); $tb2->separator; $tb2->ToolButton(-image => 'navhome22', -tip => 'home', -command => \&home); $tb2->ToolButton(-image => 'actreload22', -tip => 'reload', -command => \&reload); MainLoop;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
sub ToolEntry { my $self = shift; my %args = @_; my $m = delete $args{-tip} || ''; my $w = delete $args{-width} || 5; my $l = $self->{CONTAINER}->Entry(%args, -width => $w); push @{$self->{WIDGETS}} => $l; $self->_packWidget($l); $self->{BALLOON}->attach($l, -balloonmsg => $m) if $m; return $l; }