Using Tk::Text sounds reasonable to me.

If you're really worried about buffering the output of the commands, why would you put it in a Tk widget at all? That will take up more memory than just the string output.

Also: IIRC matlab has a "shell" interface, which means you don't start matlab itself for each command, instead you start it once, and then send commands to its STDIN and read its STDOUT for the output. That can get complicated (mainly because you can run into deadlocks) but it's certainly possible. See perlipc and IPC::Open3 and Tk::fileevent.

Update: If it's possible in your situation, you can simplify your program by using the Tk::Text (or Tk::ROText) widget for output only, and let the user enter the commands in a seperate text field below the output widget. That way you won't have to do all kinds of funky things with the keyboard events.


In reply to Re: tty in Tk app by Joost
in thread tty in Tk app by gri6507

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.