Thread Tk::Tree und beispiele (6 answers)
Opened by deepblack at 2005-02-11 11:40

renee
 2005-02-11 12:26
#42858 #42858
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Ich verstehe nicht so ganz, was du für ein Problem mit Tk::Tree hast...

Hier ein Beispielcode:
Code: (dl )
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#! /usr/bin/perl

use strict;
use warnings;
use Tk;
use Tk::Tree;
use Tk::Label;

my $top = new MainWindow( -title => "OSS NETWORK");
my $label = $top->Label(-width=>15);


my $tree = $top->Scrolled( 'Tree',
-separator => '/',
-background => 'white',
-foreground => 'blue',
-relief => 'groove',
-exportselection => 1,
-scrollbars => 'oe',
-height => 20,
-width => 40,
-itemtype => 'text',
-selectmode => 'extended',
-browsecmd => sub {
my $DN = shift;
$label->configure(-text=>$DN);
}
);
# Pack the tree.

$tree->pack( -expand => 'yes',
-fill => 'both',
-padx => 15,
-pady => 15,
-side => 'top' );

$label->pack( -expand => 'yes',
-fill => 'both',
-padx => 15,
-pady => 15,
-side => 'top' );

# Pack the label.

my @list = qw( PLMN-PLMN PLMN-PLMN/BSC-49567 PLMN-PLMN/BSC-49566 PLMN-PLMN/BSC-49560 PLMN-PLMN/BSC-49567/BCF-1 PLMN-PLMN/BSC-49567/BCF-5 PLMN-PLMN/BSC-49567/BCF-5/BTS-7 PLMN-PLMN/BSC-49567/BCF-2 PLMN-PLMN/BSC-49567/BCF-1/BTS-A);

foreach ( '/', @list ) {
my $text = (split( /\//, $_ ))[-1];

#If we're on /, let's make its label blank.
#
if ($_ eq '/') {
$text = "";
}
# Add the item (in $_) with $text as the label.
#
$tree->add( $_, -text => $text );
}
$tree->autosetmode();

MainLoop();
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread Tk::Tree und beispiele