Besten Dank "# Kein Kommentar"!
genau sowas habe ich gesucht.
Hier nochmal Dein Beispiel angepasst an meinen direkten Wunsch ;-):
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
#! /usr/bin/perl
use warnings;
use strict;
use Tk;
my $mw=MainWindow->new(-title=>"Hauptfenster");
createWindowandWait();
print "fertig!\n";
Tk::MainLoop();
sub createWindowandWait{
my $window = $mw->Toplevel();
$window->Button(
-text => 'neues Toplevel-Fenster',
-command => sub{
my $ok = undef;
my $window2 = $mw->Toplevel();
$window2->Button(
-text => 'ok!',
-command => sub{ $ok = 1;}
)->pack();
$window2->focusForce();
# warte solange bis variable '$ok' den wert true hat:
$window2->waitVariable(\$ok);
print "funktioniert ;-), besten Dank!";
$window2->destroy();
}
)->pack();
}