Schrift
[thread]5204[/thread]

HList columnWidth: etwas wie width="100%" in HTML (Seite 3)

Leser: 2


<< |< 1 2 3 >| >> 22 Einträge, 3 Seiten
styx-cc
 2006-06-09 00:46
#45647 #45647
User since
2006-05-20
533 Artikel
BenutzerIn

user image
[quote=ptk,08.June.2006, 22:12]Sieh an, auch was gelernt. <Configure> könnte aber für andere Widgets, die -sizecmd nicht kennen, nützlich sein.[/quote]
Ich hab hier so ne nette Referenz:
ISBN: 3-89721-200-5
Perl/Tk - kurz&gut
von Stephen O. Liedie

Anschauen lohnt, finde ich und ist auch recht preiswert.

MfG\n\n

<!--EDIT|styx-cc|1149799933-->
Pörl.
styx-cc
 2006-06-12 01:53
#45648 #45648
User since
2006-05-20
533 Artikel
BenutzerIn

user image
Soo.., wie versprochen eine Loesung:

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
#!/usr/bin/perl -w
use strict;
#use warnings;

use Tk;
use Tk::HList;
use Tk::ItemStyle;

my $main = tkinit();

my $hlist = $main -> HList(-header => 1, -columns => 2, -sizecmd => \&on_resize)
->pack(-fill => 'both', -expand => 1);

$hlist -> header('create', 0, -text => "Aenderung");
$hlist -> header('create', 1, -text => "Name123");

#spaltenbreite fuer spalte 0 festlegen
my $first_col = 65;
$hlist -> columnWidth(0, $first_col);


my @values = qw /test testtest2 test3 testtest4 test5 testtest6 test7 testtest8/;


my $blue_style = $hlist -> ItemStyle('text', -background => "lightblue");
my $red_style = $hlist -> ItemStyle('text', -background => "red");


#Elemente aus @values in $hlist einfuegen,
#je zwei Elemente in eine Zeile

my $j = 0;

for (my $i=0; $i <= ($#values/2); $i++) {

$hlist -> add($i);
$hlist -> itemCreate($i, 0, -text => $values[$j], -style => ($i % 2) ? $blue_style : $red_style); #alternierende Farbe
$j++;
$hlist -> itemCreate($i, 1, -text => $values[$j], -style => ($i % 2) ? $blue_style : $red_style); #alternierende Farbe
$j++;
}

MainLoop;

sub on_resize {
my $width = $hlist->width;
$hlist -> columnWidth(1, $width-$first_col-15) #-15 als Tolleranz fuer Rahmen etc.
}


Hoffe das des jetzt nicht uberfluessig war..

Mfg
Pörl.
<< |< 1 2 3 >| >> 22 Einträge, 3 Seiten



View all threads created 2006-06-06 18:12.