#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::HList; use Tk::ItemStyle; my $variable; my $fenster = new MainWindow; my $hl = $fenster->HList(-width => 50,)->pack(); my $style = $hl->ItemStyle('text', -foreground => '#FF0000', -selectforeground => '#FF0000' ); my $toplevel = $fenster->toplevel; my $menubar = $toplevel->Menu(-type => 'menubar'); $toplevel->configure(-menu => $menubar); my $datei = $menubar->cascade(-label => '~Datei', -tearoff => 0); $datei->command(-label => 'Zeige', -command => sub{nickchange()}); $datei->command(-label => 'Quit', -command => [$fenster=>'destroy']); $hl->repeat(1000, sub{print $variable;}); MainLoop; sub nickchange { my $window2 = $fenster->Toplevel; my $text = $window2->Label(-text => "Nickname eingeben")->pack(); my $entry = $window2->Entry()->pack(); my $button = $window2->Button(-text => 'Ok',-command => [\&action,$window2,$entry])->pack(); } sub action { my ($window2,$entry) = @_; my $eingabe = $entry->get(); $window2->destroy(); $variable = $eingabe; }