Leser: 1
4 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
my $main = tkinit;
$main->Label(-text => 'Hallo')->pack();
$main->Button(-text => 'change', -command => \&foo)->pack();
MainLoop();
sub foo {
$main->destroy();
$main = tkinit;
$main->Label(-text => 'blubb')->pack();
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
my $main = tkinit;
my $label = $main->Label(-text => 'Hallo')->pack();
$main->Button(-text => 'change', -command => [\&foo,$label])->pack();
MainLoop();
sub foo {
my ($label) = @_;
$label->configure(-text => 'blubb')->pack();
}
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
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
my %widget;
my $text;
my $temp = 1;
$widget{main} = MainWindow->new();
$widget{frame} = $widget{main}->Frame(-width => 65, -height => 20);
$widget{frame}->packPropagate(0);
$widget{frame}->pack(-side => 'top');
$widget{label} = $widget{frame}->Label(-textvariable => \$text);
$widget{exit} = $widget{main}->Button(-text => 'quit', -command => sub { $widget{main}->destroy(); });
$widget{change} = $widget{main}->Button(-text => 'change', -command => \&change);
$widget{entry} = $widget{frame}->Entry(-textvariable => \$text);
$widget{label}->pack(-side => 'top');
$widget{exit}->pack(-side => 'right');
$widget{change}->pack(-side => 'left');
MainLoop();
sub change {
if($temp) {
$widget{label}->packForget();
$widget{entry}->pack(-side => 'top');
$temp = 0;
} else {
$widget{entry}->packForget();
$widget{label}->pack(-side => 'top');
$temp = 1;
}
}
4 Einträge, 1 Seite |