in reply to Re: embedding xterm in perl/tk window
in thread embedding xterm in perl/tk window

After managing to find the right size I've stuck into another problem. I am opening xterm and executing a program

xterm -into $someid -e programname

but when the program finishes xterm disapears without leaving time to view what happened.

I tried xterm -into $someid -hold -e programname, but then when I close the container window an xterm process keeps staying running!

I could not figure out a simple way to make it behave in a "Press any key to end" way, without depending on the program executed to do so.

Thank you for the linking help also!

Replies are listed 'Best First'.
Re^3: embedding xterm in perl/tk window
by BrowserUk (Patriarch) on Oct 07, 2007 at 19:24 UTC
Re^3: embedding xterm in perl/tk window
by graff (Chancellor) on Oct 07, 2007 at 23:22 UTC
    Let's take a step back and talk about why you are using an xterm this way. What does the xterm process give you that a basic Tk::Text window does not? If you are simply trying to display the output of a unix shell command inside a Perl/Tk app, the usual way to do that is:
    use strict; use Tk; my $mw = MainWindow->new; my $tx = $mw->Scrolled('Text', -height => 24, -width => 90)->pack(); my $data = `programname`; $tx->insert( '0.0', $data ); MainLoop;
    (That worked pretty well for me when I put "ls" in place of "programname".)

    Presumably there's more to your app than that, but you get the idea. If that's the sort of thing you're after, using an embedded xterm, while really cool, is more complicated than it needs to be. If you need something more, what would that be, exactly?

      Actually I have a ROText for outputing formated (nicely colored, parsed etc) data from some programs that my perl/tk application calls.

      Some programs ask for feedback from the user in a complicated way that I do not dare to use open3 to handle it. So, I thought that I could embed a terminal (xterm/konsole) as an "advanced" mode.

      For now I just call xterm or konsole as an external window, but I would prefer a pretier solution.

        Some programs ask for feedback from the user in a complicated way

        Can you edit these programs? If you can, change them so that they accept all necessary user input as command line args, rather than asking for input from the user after they start.

        If you can't edit them, have you checked to make sure whether they support a "non-interactive" mode of operation?

        If they absolutely require manual user input after they start, is it the case that the user is able to know what inputs will be needed before running the program? (Or is it instead the case that the program has to show some output, and then ask for manual input that might vary depending on what was shown and what the user wants to do?)

        If the choice is between a "free-floating" xterm (launched by your perl/tk app) vs. one that is embedded in your Tk window, and the former is working while the latter is proving to be a difficult challenge, it sounds like something that isn't really broken, and so maybe shouldn't be fixed.

Re^3: embedding xterm in perl/tk window
by nikwasi (Initiate) on Mar 02, 2011 at 19:00 UTC
    This is an old thread, but I have ta solution to keep the xterm active. Adding bash command to -e.
    $cmd = "\'ls; bash\'"; system("xterm -into $xtId -hold -e $cmd &");