I have a script that does pretty much what you require. It was written some time ago so doesn't have best practices like use strict but that would be easy to fix. Here it is.

$SIG{CHLD} = "IGNORE"; use Tk; use integer; $rlApps = [map{[m<^(.*):(.*)>m]} <DATA>]; $longestName = 0; foreach (@$rlApps) { my $l = length $_->[0]; $longestName = $l if $l > $longestName; } chomp($hostName = `/usr/bin/hostname`); $ENV{DISPLAY} = $hostName . $ENV{DISPLAY} if $ENV{DISPLAY} eq ":0.0"; $bgColour = "LightSteelBlue3"; %buttonColours = ( "-background" => "grey35", "-foreground" => "yellow2", "-activebackground" => "grey45", "-activeforeground" => "yellow", "-disabledforeground" => "grey55"); $mainWin = MainWindow->new( "-background" => $bgColour); $mainWin->title("xlaunch"); $mainWin->resizable(0, 0); $appsSelectFrame = $mainWin->Frame( "-relief" => "ridge", "-background" => $bgColour, "-borderwidth" => 2)->pack( "-side" => "top", "-fill" => "y", "-expand" => 1); foreach (0 .. $#{$rlApps}) { my $buttonName = $rlApps->[$_]->[0] . "Button"; $$buttonName = $appsSelectFrame->Button( "-text" => $rlApps->[$_]->[0], %buttonColours, "-width" => $longestName)->pack( "-side" => "top", "-padx" => 5, "-pady" => 5); $$buttonName->configure( "-command" => [\&invokeApp, $_]); } $controlButtonFrame = $mainWin->Frame( "-relief" => "flat", "-background" => $bgColour, "-borderwidth" => 2)->pack( "-side" => "top"); $controlButtonFrame->Button( "-text" => "Quit", %buttonColours, "-command" => sub {exit;})->pack( "-side" => "right", "-padx" => 5, "-pady" => 5); MainLoop(); sub invokeApp { my $appSub = shift; my $cmd = $rlApps->[$appSub]->[1]; my $pid; if($pid = fork) { return; } elsif(defined($pid)) { exec $cmd; } else { die "Fork error: $!\n"; } } __END__ Acrobat Reader:/usr/local/bin/acroread CGM Viewer:/usr/openwin/bin/xterm -sb -sl 500 -title "CGM Viewer" -e / +ogis00/app/bin/cgm_viewer Petrobank:/usr/openwin/bin/xterm -sb -sl 500 -title "Petrobank" -e /og +is00/app/bin/petrobank Geolog:/usr/openwin/bin/xterm -sb -sl 500 -title "Geolog" -e /ogis00/a +pp/bin/geolog Netscape:/usr/dt/bin/netscape WebPlot:/usr/openwin/bin/xterm -sb -sl 500 -title "WebPlot" -e /ogis00 +/app/bin/webplot Xgeo:/usr/openwin/bin/xterm -sb -sl 500 -title "Xgeo" -e /ogis00/app/b +in/xgeo ZMAP:/usr/openwin/bin/xterm -sb -sl 500 -title "ZMAP" -e /ogis00/app/b +in/zmap Calculator:/usr/dt/bin/dtcalc File Manager:/usr/dt/bin/dtfile Xterm:/usr/openwin/bin/xterm -sb -sl 2000

I hope you find it useful.

Cheers,

JohnGG


In reply to Re: Program design with GUI interface by johngg
in thread Program design with GUI interface by snailwinks

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.