Try using an entry widget like so:
use Tk; use warnings; use diagnostics; use strict; my $text; my $mw = MainWindow->new; $mw->title("PerlRun"); $mw->Entry(-width => 30, -textvariable, \$text)->pack(-anchor => 'nw', -side => 'top'); $mw->Button(-text => " Run ", -command => \&runprog ) ->pack(-side => 'left', -anchor => 'sw'); $mw->Button(-text => "Done", -command => sub { exit }) ->pack(-side => 'left', -anchor => 'sw'); sub runprog { system($text); } MainLoop;
If you wanted to use the Text widget, than your only problem was that you were trying to run the command on the ref to the $text widget instead of the variable in the runprog sub, so.. what you really wanted to do is this:
my $cmd = $text->get('0.1','end'); chomp $cmd; system($cmd);
Take a look at the Mastering Perl/Tk by Steve Liddie... great book :)
Cheers,
JamesNC

In reply to Re: Perl/Tk run program by JamesNC
in thread Perl/Tk run program by st_possenti

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.