Debian Codegraph @

examples/embed

raw
1 #!/usr/local/bin/perl -w
2
3 use Tk;
4 use IO::File;
5 $ENV{'PERL5LIB'} = join(($^O eq 'MSWin32') ? ';' : ':',@INC);
6
7 if (@ARGV)
8 {
9 open(STDOUT,">&STDERR");
10 my $id = shift;
11 print "$id\n";
12 my $mw = MainWindow->new('-use' => oct($id));
13 print "id = $id, use=",$mw->cget('-use')," mw id=",$mw->id,"\n";
14 $mw->Label(-text => "This is process $$ using $id")->pack;
15 $mw->Button(-text => 'Quit', -command => [destroy => $mw])->pack;
16
17 MainLoop;
18 }
19 else
20 {
21 my $mw = MainWindow->new;
22 my $f = $mw->Frame(-borderwidth => 6, -relief => 'sunken', -container => 1)->pack;
23 my $id = $f->id;
24 $mw->Label(-text => "This is process $$ providing $id")->pack;
25 $mw->Button(-text => 'Quit', -command => [destroy => $mw])->pack;
26 my $fh = IO::File->new("$^X $0 $id|");
27 MainLoop;
28 $fh->close;
29 }