in reply to Program design with GUI interface
First, system may not be the best option if you want to direct the output directly to a text box, you will need to use "piped opens" or "IPC::Open3"( or a similar method) along with Tk's fileevent to read the output. This will collect and display the output of long-running programs, without "blocking the gui". Additionally, this will allow you to run more than one command at a time. Backticks could be used to capture the output, if the command will complete quickly.
A cool way to do this, would be with a Notebook widget, and a menu. The menu would allow you to select which command to run, and then it would open a new notebook page with the command name in the tab-text, and an entry widget for the extra options, and an output text widget on the page.
Another ready to go module which will help you do this is the Tk::ExecuteCommand module. Here is a simple example, but you can launch commands as many as you want, and they will open in a new window.
#!/usr/bin/perl -w use Tk; use Tk::ExecuteCommand; use Tk::widgets qw/LabEntry/; use strict; my $mw = MainWindow->new; my $top = $mw->Toplevel; $top->withdraw; my $ec = $top->ExecuteCommand( -command => '', -entryWidth => 50, -height => 10, -label => '', -text => 'Execute', )->pack; $ec->configure(-command => 'date; sleep 10; date'); my $button = $mw->Button(-text =>'Do_it', -background =>'hotpink', -command => sub{ $top->deiconify; $top->raise; $ec->execute_command; $top->withdraw}, )->pack; MainLoop;
|
|---|