use Time::HiRes qw(sleep); use Tk; use Tk::Text; use Tk::Scrollbar; #================================ Variablen =========================================================== $trigger = 0; ################################# TK-Abschnitt ######################################################## #================================ Hauptfenster ======================================================== $HF = new MainWindow (); $HF->geometry('430x350'); #================================ Text-Frame ========================================================== $Frame1 = $HF -> Frame(-width => 427, -height => 220,-borderwidth => 3, -relief => groove, -bg => black); $Frame1->place(-x=> 2, -y=> 19); $Textframe = $Frame1->Scrolled(Text, -wrap,none, -scrollbars => 'se', -height => 12, -width => 55, -bg => black, -fg => white)->pack(-expand => 'yes', -fill => 'both', -side => 'left'); #================================ Buttons ============================================================= $BtnStart = $HF->Button(-text=>"START", -command => sub {$trigger = 0;erstell_daten();}, -borderwidth => 2,-relief => raised,-width => 14, -font=>"Century 10"); $BtnStart->place(-x=> 2, -y=>260); $BtnStop = $HF->Button( -text=>"STOP", -command => sub {$trigger = 1;}, -borderwidth => 2,-relief => raised,-width => 14, -font=>"Century 10"); $BtnStop->place(-x=> 140, -y=> 260); $BtnQuit = $HF->Button( -text=>"Quit", -command => sub{exit;},-width => 14, -borderwidth => 2,-relief => raised, -font=>"Century 10"); $BtnQuit->place(-x=> 280, -y=> 260); MainLoop(); ################################# Ende TK-Abschnitt ################################################### sub erstell_daten () { while(1) { if($trigger eq 1){return} sleep 1; $zaehler++; $Textframe->insert("end", "\n$zaehler"); $HF->update(); } }