#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::ExecuteCommand; my %commands = ( #buttontext => command sleep => 'sleep 20', dir => 'dir', ls => 'ls -la', ); my $mw = MainWindow->new; foreach my $key (keys %commands){ $mw->Button(-text => $key, -command=>[\&execute, $commands{$key}] )->pack; } $mw->Button(-text => 'Quit', -command=> sub{Tk::exit} )->pack; MainLoop; sub execute { my $command = shift; my $tl = $mw->Toplevel( ); $tl->title($command); $tl->Button(-text => "Close", -command => sub { $tl->withdraw })->pack; my $ec = $tl->ExecuteCommand( -command => $command, -entryWidth => 50, -height => 10, -label => '', -text => 'Execute', )->pack; $ec->bell; $ec->update; }