Just because I haven't done Tk for a while. Probably needs some tweaking for directories and paths.

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11130955 use warnings; use Tk; use Path::Tiny; my $code; my $file; my $execute; my $mw = MainWindow->new; my $button = $mw->Button(-text => 'Execute', -command => \&execute, -state => 'disabled', )->pack(-side => 'bottom'); my $frame = $mw->Frame->pack(-fill => 'both', -expand => 1); $frame->Label(-text => 'Perl Script', -fg => 'blue', )->grid(-row => 1, -column => 1, -sticky => 'ew'); $frame->Label(-text => 'Data File', -fg => 'blue', )->grid(-row => 1, -column => 2, -sticky => 'ew'); my $codelist = $frame->Scrolled(Listbox => -scrollbars => 'osoe', -exportselection => 0, )->grid(-row => 2, -column => 1, -sticky => 'nsew'); my $filelist = $frame->Scrolled(Listbox => -scrollbars => 'osoe', -exportselection => 0, )->grid(-row => 2, -column => 2, -sticky => 'nsew'); $frame->gridRowconfigure( 2, -weight => 1 ); $frame->gridColumnconfigure( $_, -weight => 1 ) for 1, 2; $codelist->bind('<ButtonRelease-1>' => sub {$code = $codelist->get($codelist->curselection); ready() } ); $filelist->bind('<ButtonRelease-1>' => sub {$file = $filelist->get($filelist->curselection); ready() } ); sub execute { $execute++; $mw->destroy; } sub ready { $code && $file and $button->configure(-state => 'normal') +} $codelist->insert(end => sort grep -x, path('.')->children(qr/\.pl$/) +); $filelist->insert(end => sort +path('.')->children(qr/\.d$/) ); MainLoop; $execute or exit; $code or die "no code selected"; $file or die "no file selected"; print "exec $code $file\n"; #exec 'perl', $code, $file; ### FIXME testing - uncomment to actually +run die "exec failed $!";

In reply to Re: TK + Script by tybalt89
in thread TK + Script by Ggavazzo

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.