Tk::Toolbar - Werkzeugleisten

Bewegliche Werkzeugleisten, sog. Toolbars werden mit Tk::Toolbar erstellt. Das Modul ist nicht standardmäßig in Tk enthalten und muss zusätzlich installiert werden. Es gibt eine Demo, in der man sich auch alle verfügbaren Buttons ansehen kann: toolbar.pl. Diese befindet sich im Verzeichnis C:\strawberry\perl\site\lib\Tk\demos\widtrib.


Perl-Quellcode

#!perl

use strict;
use warnings;
use Tk;
use Tk::ToolBar;

my $mw = Tk::MainWindow->new();

my $tb = $mw->ToolBar(
	-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"]);

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);

$mw->MainLoop();

Eingebaute Icons für den Toolbar

Die nachstehenden Icons werden mit Tk::ToolBar standardmäßig ausgeliefert. Sie werden über den Namen referenziert und in den Toolbar eingebettet. Um Beispielsweise das Bild mit der Büroklammer für ein Attachment in den Toolbar einzufügen reicht folgende Zeile aus:

$toolbar_object->ToolButton(-image => 'actattach16', -command => sub{ print "Mach was"; });
Icon Name
actattach16 actattach16
actbookmark16 actbookmark16
actbookmarknew16 actbookmarknew16
actcheck16 actcheck16
actcross16 actcross16
actexit16 actexit16
acthelp16 acthelp16
actitemadd16 actitemadd16
actitemdelete16 actitemdelete16
actlock16 actlock16
actredo16 actredo16
actreload16 actreload16
actrun16 actrun16
actstop16 actstop16
actundo16 actundo16
actunlock16 actunlock16
appbook16 appbook16
appbookopen16 appbookopen16
appboxes16 appboxes16
appbox16 appbox16
appbrowser16 appbrowser16
appcalc16 appcalc16
appclock16 appclock16
appdate16 appdate16
apppencil16 apppencil16
appsheet16 appsheet16
apptool16 apptool16
apptools16 apptools16
appuser16 appuser16
appusers16 appusers16
appwp16 appwp16
cal1day16 cal1day16
cal5days16 cal5days16
cal7days16 cal7days16
calappointment16 calappointment16
calbell16 calbell16
callist16 callist16
calmonth16 calmonth16
caltoday16 caltoday16
caltodo16 caltodo16
connecting16 connecting16
connectno16 connectno16
connectyes16 connectyes16
devcdmount16 devcdmount16
devcdunmount16 devcdunmount16
devdiskmount16 devdiskmount16
devdiskunmount16 devdiskunmount16
devfloppymount16 devfloppymount16
devfloppyunmount16 devfloppyunmount16
devnetwork16 devnetwork16
devpc16 devpc16
devscanner16 devscanner16
devscreen16 devscreen16
devspeaker16 devspeaker16
editcopy16 editcopy16
editcut16 editcut16
editdelete16 editdelete16
edit16 edit16
editpaste16 editpaste16
editshred16 editshred16
edittrash16 edittrash16
fileclose16 fileclose16
filedocument16 filedocument16
filefind16 filefind16
filenew16 filenew16
fileopen16 fileopen16
fileprint16 fileprint16
filesave16 filesave16
folder16 folder16
folderhtml16 folderhtml16
folderlocked16 folderlocked16
foldernew16 foldernew16
folderopen16 folderopen16
mailforward16 mailforward16
mailget16 mailget16
mail16 mail16
mailreplyall16 mailreplyall16
mailreply16 mailreply16
mailsend16 mailsend16
nav1downarrow16 nav1downarrow16
nav1leftarrow16 nav1leftarrow16
nav1rightarrow16 nav1rightarrow16
nav1uparrow16 nav1uparrow16
nav2downarrow16 nav2downarrow16
nav2leftarrow16 nav2leftarrow16
nav2rightarrow16 nav2rightarrow16
nav2uparrow16 nav2uparrow16
navback16 navback16
navdown16 navdown16
navforward16 navforward16
navhome16 navhome16
navup16 navup16
playeject16 playeject16
playend16 playend16
playpause16 playpause16
playstart16 playstart16
playstop16 playstop16
textblock16 textblock16
textbold16 textbold16
textbottom16 textbottom16
textcenter16 textcenter16
textitalic16 textitalic16
textleft16 textleft16
textmiddle16 textmiddle16
textmove16 textmove16
textright16 textright16
textsortdec16 textsortdec16
textsortinc16 textsortinc16
text16 text16
texttop16 texttop16
textunder16 textunder16
viewchoose16 viewchoose16
viewdetailed16 viewdetailed16
viewicon16 viewicon16
viewmag-16 viewmag-16
viewmag16 viewmag16
viewmag+16 viewmag+16
viewmulticolumn16 viewmulticolumn16
viewtext16 viewtext16
viewtree16 viewtree16
actattach22 actattach22
actbookmark22 actbookmark22
actbookmarknew22 actbookmarknew22
actexit22 actexit22
acthelp22 acthelp22
actlock22 actlock22
actredo22 actredo22
actreload22 actreload22
actrun22 actrun22
actstop22 actstop22
actundo22 actundo22
actunlock22 actunlock22
appbook22 appbook22
appbookopen22 appbookopen22
apppencil22 apppencil22
apptool22 apptool22
connecting22 connecting22
connectno22 connectno22
connectyes22 connectyes22
devscreen22 devscreen22
editcopy22 editcopy22
editcut22 editcut22
editdelete22 editdelete22
edit22 edit22
editpaste22 editpaste22
editshred22 editshred22
edittrash22 edittrash22
fileclose22 fileclose22
filefind22 filefind22
filenew22 filenew22
fileopen22 fileopen22
fileprint22 fileprint22
filesave22 filesave22
foldernew22 foldernew22
mailforward22 mailforward22
mailget22 mailget22
mail22 mail22
mailreplyall22 mailreplyall22
mailreply22 mailreply22
mailsend22 mailsend22
nav1downarrow22 nav1downarrow22
nav1leftarrow22 nav1leftarrow22
nav1rightarrow22 nav1rightarrow22
nav1uparrow22 nav1uparrow22
nav2downarrow22 nav2downarrow22
nav2leftarrow22 nav2leftarrow22
nav2rightarrow22 nav2rightarrow22
nav2uparrow22 nav2uparrow22
navback22 navback22
navdown22 navdown22
navforward22 navforward22
navhome22 navhome22
navup22 navup22
playeject22 playeject22
playend22 playend22
playpause22 playpause22
playstart22 playstart22
playstop22 playstop22
textblock22 textblock22
textbold22 textbold22
textcenter22 textcenter22
textitalic22 textitalic22
textleft22 textleft22
textright22 textright22
text22 text22
textunder22 textunder22
viewchoose22 viewchoose22
viewdetailed22 viewdetailed22
viewicon22 viewicon22
viewmag-22 viewmag-22
viewmag22 viewmag22
viewmag+22 viewmag+22
viewmulticolumn22 viewmulticolumn22
viewtext22 viewtext22
viewtree22 viewtree22
Top