in reply to how to implement ipc on linux?

If you are using X, and are willing to use Tk, there is the easy-2-use Tk::Execute::Command module.
#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::ExecuteCommand; my $mw = MainWindow->new; my $ec_dir = $mw->ExecuteCommand( -command => 'dir; sleep 10; dir;', -entryWidth => 50, -height => 10, -label => '', -text => 'Execute dir ', )->pack; my $ec_date = $mw->ExecuteCommand( -command => 'date; sleep 10; date;', -entryWidth => 50, -height => 10, -label => '', -text => 'Execute date ', )->pack; my $dir_but = $mw->Button( -text => 'Execute dir', -background => 'hotpink', -command => sub{ $ec_dir->execute_command })->pack; my $date_but = $mw->Button( -text => 'Execute date', -background => 'lightgreen', -command => sub{ $ec_date->execute_command })->pack; MainLoop;

I'm not really a human, but I play one on earth. flash japh

Replies are listed 'Best First'.
Re^2: how to implement ipc on linux?
by redss (Monk) on Feb 16, 2005 at 22:08 UTC
    thanks for the excellent example (and I am using Tk now!) but I don't really need all those unecessary widgets on the screen (like stdout).

    I just need something like (pseudocode)

    system(command) until (done or user_aborted_with_keypress) quit if done; goto next step if user hit 'N' goto previous step if user hit 'P'
    I could use Tk if it would be more sparse on the interface tho...

    thanks!

      I don't have an example handy, but Tk::ExecuteCommand has "advertised subwidgets", which means you can access the various components separately, and change their appearance. So you could make the stdout textbox, nearly invisible. For that matter, you could run it with the window "withdrawn", to make it totally invisible. You also could setup custom key bindings, to call the same "Quit" subroutine, as the Execute/Stop button has. Read perldoc Tk::ExecuteCommand and look for the "ADVERTISED SUBWIDGETS" section. You possibly could do something like:
      my $rotext = $ec->Subwidget(ROText); $rotext->configure(-height => 0);
      and you could add key bindings, like
      $text->bind('<Control-r>',sub{$ec->kill_command });
      Of course, this only works from X, if you want it to work from the command line, try POE; maybe the POE Cookbook has some examples.

      I'm not really a human, but I play one on earth. flash japh