#!/usr/bin/perl -w use Tk; use strict; my ($status, $abbruch); my $Form2 = MainWindow->new; $Form2->title("StoppLoop"); $Form2->geometry("200x140+8+8"); my $bt_start = $Form2->Button( -text => "starten", -command => \&starte_schleife )->pack(-pady=>10, -padx=>10); my $txt_status = $Form2->Entry( -textvariable => \$status, -width => '150')->pack(-pady=>10, -padx=>10); my $bt_stop = $Form2->Button( -text => "stoppen", -command => \sub{$abbruch=1} )->pack(-pady=>10, -padx=>10); MainLoop; sub starte_schleife{ undef($abbruch); for my $i(1..10000){ $status = ($abbruch)?"Abbruch durch Benutzer" : "$i. Schleifendurchgang"; $Form2->update; $i=10000 if defined $abbruch; } }