Can I somehow find the width and height of the xterm?

Assuming a bash shell, you can add these two lines to your .bashrc:

export LINES export COLUMNS
The xterm sets those two environment variables to the window's height and width, respectively, in characters, but since the xterm being run by your Perl/Tk script is in a sub-shell, the values for that particular xterm window won't be accessible by the perl script. (You only get to see the values for the xterm shell from which the perl script was run, as $ENV{LINES}, $ENV{COLUMNS}.

You can control the xterm size on start-up by adding this option:  -geometry WxH (where W and H are width and height in characters). In the code that you cited (embedding xterm into a Tk app by zentara) just add that option to the string being passed to system() at line 46.

Using "-geometry 78x23" actually improved its behavior for me; YMMV. It seems that 80x24 is the typical default xterm size, but if your font is different from the one zentara used, your display might not seem to work right.

You'll probably need to experiment for a while with font sizes for the xterm and pixel sizes for the containing widget, to get a feel for how they relate.

(BTW, check out What shortcuts can I use for linking to other information? to see the easy way to link to other nodes at the monastery. -- Update: I changed this link, because Writeup Formatting Tips isn't the direct source for info about linking.)


In reply to Re: embedding xterm in perl/tk window by graff
in thread embedding xterm in perl/tk window by diamantis

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.