Thread [Tk] frame ändert seine größe (8 answers)
Opened by wayne95 at 2011-09-17 00:13

FIFO
 2011-09-17 08:18
#152514 #152514
User since
2005-06-01
469 Artikel
BenutzerIn

user image
Hi,

Was Du brauchst, ist packPropagate(0), schau Dir auch mal die pack-Optionen -fill und -expand an. Eine gute Zusammenfassung findest Du hier (Mastering Perl/Tk) (link entfernt).
Beispielskript mit Deinen Widgets:
Code (perl): (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
62
63
64
65
66
67
68
69
70
use warnings;
use strict;
use Tk;

my $hoehe = 80;
my $breite = 600;
my $hauptfenster = Tk::MainWindow->new();
my $fensterL = $hauptfenster->Canvas(
    -height     => $hoehe,
    -width      => $breite / 4,
    -background => 'chocolate',
    -relief     => 'groove',
    -bd         => 3
)->pack(
    -side       => 'left',
    -fill       => 'both',
    -expand     => 1
);
my $fensterM = $hauptfenster->Frame(
    -height     => $hoehe,
    -width      => $breite / 4,
    -background => 'chocolate1',
    -relief     => 'groove',
    -bd         => 3
)->pack(
    -side       => 'left',
    -fill       => 'both',
    -expand     => 1
);
my $fensterR = $hauptfenster->Frame(
    -height     => $hoehe,
    -width      => $breite / 4,
    -background => 'chocolate2',
    -relief     => 'groove',
    -bd         => 3
)->pack(
    -side       => 'left',
    -fill       => 'both',
    -expand     => 1
);
my $fenster = $hauptfenster->Frame(
    -height     => $hoehe,
    -width      => $breite / 4,
    -background => 'chocolate3',
    -relief     => 'groove',
    -bd         => 3
)->pack(
    -side       => 'left',
    -fill       => 'both',
    -expand     => 1
);

$fensterL->packPropagate(0);
$fensterM->packPropagate(0);

my $anmeld = $fensterL->Label(
    -text => "Anmeldename"
)->pack(
    -side   => 'top',
    -expand => 0,
    -fill   => 'none'
);
my $test = $fensterM->Button(
    -text => "Button"
)->pack(
    -expand => 1, 
    -fill   => 'none'
);

MainLoop();


Gruß FIFO

edit @pq: sorry, ich arbeite tatsächlich mit der gedruckten Buchausgabe und hab beim Link nicht mehr genau hingeschaut.
@wayne: Wenn Du ernsthaft mit Tk arbeitest, besorg Dir "Mastering Perl/Tk" vom O'Reilly-Verlag, ist zwar nicht ganz neu, aber sehr hilfreich.


Editiert von FIFO: typo
Last edited: 2011-09-17 14:12:49 +0200 (CEST)
Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it? -- Brian Kernighan: "The Elements of Programming Style"

View full thread [Tk] frame ändert seine größe