Leser: 6
6 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 28 29 30 31 32 33 34 35 36 37
#!/usr/bin/perl use strict; use warnings; use Tk; use strict; use Tk::DirTree; use Cwd; my $mw = MainWindow->new; $mw->geometry("300x400"); $mw->title("DirTree Example"); my $CWD = Cwd::cwd(); my $DIR_TREE = $mw->Scrolled('DirTree', -scrollbars => "osoe", -width => 30, -height => 25, -exportselection => 1, -browsecmd => sub {$CWD = shift}, -command => \&show_cwd)->pack(-fill => "both", -expand => 1); $DIR_TREE->chdir($CWD); my $button_frame = $mw->Frame()->pack(-side => "bottom"); $button_frame->Button(-text => "Ok", -command => \&show_cwd)->pack(-side => "left"); $button_frame->Button(-text => "Exit", -command => sub{exit})->pack(-side => "left"); sub show_cwd { $mw->messageBox(-message => "Directory Selected: $CWD", -type => "ok"); } MainLoop;
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
#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::Label; use Tk::HList; my $mw = MainWindow->new(); my $label = $mw->Label(-width=>15); my $hlist = $mw->HList( -itemtype => 'text', -separator => '/', -selectmode => 'single', -browsecmd => sub { my $file = shift; $label->configure(-text=>$file); } ); foreach ( qw(/ /home /home/ioi /home/foo /usr /usr/lib) ) { $hlist->add($_, -text=>$_); } $hlist->pack; $label->pack; MainLoop;
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
#!/usr/bin/perl use strict; use warnings; # Module einbinden use Tk; use Tk::Tree; use utf8; # Fenster erstellen my $mw = MainWindow -> new; # Hilfetext my $text = 'Doppelklick oder <Enter> auf Zeile'; $mw -> Label (-textvariable => \$text) -> pack (-side => 'top'); # Verzeichnisbaum erstellen my $tree = $mw -> Tree (-command => sub {$text = shift}, -width => 30, -height => 20) -> pack (-anchor => 'nw'); # Zeilen in Verzeichnisbaum einfügen foreach(qw (a b b.eins b.zwei b.drei b.drei.alfa b.drei.beta b.drei.beta.rot b.drei.beta.blau b.drei.beta.grün b.drei.gamma b.vier c d)) { my @t = split (/\./, $_); $tree->add($_, -text => $t[-1]); } # Weichen stellen $tree->autosetmode(); # Beenden-Button $mw -> Button (-text => 'Beenden', -command => sub {exit}) -> pack (); # Fenstererstellung ausführen MainLoop;
6 Einträge, 1 Seite |