![]() |
|< 1 2 >| | ![]() |
20 Einträge, 2 Seiten |
perl -MTk -e "tkinit->Label(-text => 'Hallo')->pack and MainLoop"
$splash->bind('<<toete>>' => sub { $splash->destroy() } );
1
2
3
4
5
6
7
$splash->after(
100,
sub {
&$f();
$splash->eventGenerate('<<toete>>', -when => 'now');
}
);
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use Tk::ROText;
use IO::File;
use POSIX qw/tmpnam/;
use File::Basename qw/dirname/;
use FindBin;
#
# create tempory file name:
#
my $File;
my $Handle;
my $Mw;
{
do {
$File = tmpnam();
}
until my $fh = new IO::File ($File, O_RDWR | O_CREAT | O_EXCL);
}
print "File: [$File]\n";
#
# create $File and open $Handle:
#
fill_in();
system('ls', '-l', dirname($File));
open($Handle, "tail -f $File|") or die "Nope: $!";
#
# Start Tk
#
tk_start();
exit;
sub tk_start {
my $mw = $Mw = new MainWindow;
#$mw->title("fileevent.pl - tmpfile: [$File]");
$mw->Label(
-text => "tmpfile: [$File]",
-anchor => 'w',
)->pack(
-fill => 'x',
-expand => 0,
);
$mw->Button(
-text => 'Daten in Datei schreiben',
-command => \&fill_in,
)->pack(
-fill => 'x',
-expand => 0,
-padx => 10,
-pady => 10,
-ipadx => 10,
);
my $t = $mw->Scrolled(
'ROText',
-scrollbars => 'oe',
-height => 10,
-width => 50,
)->pack(
-fill => 'both',
-expand => 1,
-pady => 10,
);
$mw->fileevent(\*$Handle, 'readable', [ \&fill_text_widget, $t ]);
MainLoop();
} # sub tk_start
sub fill_in {
system("date >> $File");
}
sub fill_text_widget {
my ($widget) = @_;
my $stat = sysread $Handle, $_, 4096;
die "sysread error: $!" unless defined $stat;
$widget->insert('end', $_);
$widget->yview('end');
} # sub fill_text_widget
END {
print "Anfang vom ENDE\n";
#$Mw->fileevent(\*$Handle, 'readable');
#$Handle->close();
unlink $File or die "Konnte '$File' nicht loeschen: $!";
print "Ende vom ENDE\n";
system "kill -9 $$";
} # END
1
2
3
4
5
6
use Tk;
$top = new MainWindow;
# $top->OnDestroy(sub { $x = 1 });
$top->waitVariable(\$x);
MainLoop;
warn "Fertig";
![]() |
|< 1 2 >| | ![]() |
20 Einträge, 2 Seiten |