kranthi has asked for the wisdom of the Perl Monks concerning the following question:

Hi Perl Monks, I am using Perl/Tk 9perl V5.10). I need to implement command prompt in my applicaton i.e when we select command from the dropdown menu, a small window should appear in the application which should process the commands that are defined by me.
I used the Text widget for the same, but sorry to say that am unable to or not getting the logic to implement the same.
I had gone through the term::ShellUI, but it will open a new process and it is not appearing as a prat of my window.
As i am new to perl Tk programming i dont know whether any implemented modules exists for the same.
Request provide me your suggestions on how to implement the same?
  • Comment on Require help in designing command prompt GUI

Replies are listed 'Best First'.
Re: Require help in designing command prompt GUI
by zentara (Cardinal) on Jul 12, 2008 at 13:52 UTC
    Tk::ExecuteCommand is very configurable. The main widgets are all advertised, meaning you can access them directly. But here is the basic idea.
    #!/usr/bin/perl use warnings; use strict; use Tk; use Tk::ExecuteCommand; my $top = MainWindow->new; my $menu = $top->Menu( -type => 'menubar' ); $top->configure( -menu => $menu ); $menu->Cascade( -label => '~Selections', -tearoff => 1, -menuitems => [ [ Button => 'dir', -command => [ \&printchoice, 'dir' ] ], [ Button => 'time', -command => [ \&printchoice, 'time' ] ], [ Button => 'ls', -command => [ \&printchoice, 'ls' ] ], ], ); my $ec = $top->ExecuteCommand( -command => '', -entryWidth => 50, -height => 10, -label => '', -text => 'Execute', )->pack; MainLoop; sub printchoice { my $choice = shift; print $choice, "\n"; $ec->configure( -command => $choice ); $ec->execute_command; $ec->bell; $ec->update; }

    I'm not really a human, but I play one on earth CandyGram for Mongo
Re: Require help in designing command prompt GUI
by psini (Deacon) on Jul 12, 2008 at 11:19 UTC

    What is the problem with the answers you got last week to this node of yours?

    Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Require help in designing command prompt GUI
by Anonymous Monk on Jul 12, 2008 at 08:35 UTC