I'm somewhat biased :-), but I would use Tk. Why? Because the coding is simpler, and the number of libraries needed is far less. Do a strace or ltrace on a Perl/Tk script, then on a Wx, Gtk, or Qt script, and you will see what I mean. Some toolkits load many 10's of un-needed libraires, just to display a window and a few widgets.

As a quick solution, you could use Tk::ExecuteCommand, here is a fairly complete example.

#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::Pane; use Tk::ExecuteCommand; my %commands = ( #buttontext => command sleep => 'sleep 20', dir => 'dir', date => 'date', date1 => 'date; sleep 5; date;', ls => 'ls -la', users => 'cat /etc/passwd', who => 'who', whomai => 'whoami', ps => 'ps mauxww', top => 'top', cat_error => 'cat foobar' ); my $width = 90; my $height = 120; my $mw = MainWindow->new(); $mw->geometry($width.'x'.$height.'+100+100'); $mw->configure(-background => 'black'); $mw->Button(-text => 'Quit', -activebackground => 'red', -highlightbackground => 'yellow', -background => 'pink', -command=> sub{Tk::exit} )->pack; my $p = $mw->Scrolled('Pane', -scrollbars => 'oe',)->pack; foreach my $key (keys %commands){ $commands{'tl'}{$key} = $mw->Toplevel(-background => 'lightsteelblu +e'); $commands{'tl'}{$key}->title($key); $commands{'ec'}{$key} = $commands{'tl'}{$key}->ExecuteCommand( -background => 'lightsteelblue', -command => $commands{$key}, -entryWidth => 50, -height => 10, -label => '', -text => 'Execute', )->pack; my $t = $commands{'ec'}{$key}->Subwidget( 'text' ); # ROText widget $t->configure(-background => 'lightyellow'); my $f1 = $commands{'tl'}{$key}->Frame(-background => 'black') ->pack(-expand => 1, -fill => 'x'); $f1->Button(-text => "Clear", -activebackground => 'lightyellow', -highlightbackground => 'white', -background => 'yellow', -command => sub { $t->delete( '1.0' => 'end' ); })->pack(-side =>'left', -padx => 70); $f1->Button(-text => "Get Status", -activebackground => 'lightgrey', -highlightbackground => 'white', -background => 'grey', -command => sub { my @return = $commands{'ec'}{$key}->get_status; #Returns a 2 element array of $? and $! from last command execut +ion. $t->insert( 'end' => "\nStatus->\t\$?=$return[0]\t\$!=$return[1] +\n\n"); $t->see('end'); })->pack(-side =>'left', -padx => 70); $f1->Button(-text => "Close", -activebackground => 'hotpink', -highlightbackground => 'white', -background => 'pink', -command => sub { $commands{'tl'}{$key}->withdraw; $commands{'button'}{$key}-> configure(-state => 'normal'); })->pack(-side => 'right', -padx => 70); $commands{'tl'}{$key}->withdraw; $commands{'button'}{$key} = $p->Button(-text => $key, -background => 'lightyellow', -activebackground => 'yellow', -command=>[\&execute, $key, ] ) ->pack(-fill => 'x',-expand => 1,-pady => 1); } MainLoop; sub execute { my $key = shift; $commands{'button'}{$key}->configure(-state => 'disabled'); $commands{'tl'}{$key}->deiconify; $commands{'tl'}{$key}->raise; $commands{'ec'}{$key}->bell; $commands{'ec'}{$key}->update; }

I'm not really a human, but I play one on earth. ..... an animated JAPH

In reply to Re: Best/Fast/Simple way to add a GUI to a batch process by zentara
in thread Best/Fast/Simple way to add a GUI to a batch process by vitoco

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.