On Thu, 19 Jan 2006, Vincent Zee wrote:

> say you want to write a more-like program. How do you know how many
> lines the terminal window can display.

Hi Vincent,

It's possible that this information might already be in your environment.
If you're using the 'bash' shell, and if the 'checkwinsize' option is set
in bash, then bash should keep track of the window size through LINES and
COLUMNS.  According to the "Art of Unix Programming":

    http://www.faqs.org/docs/artu/ch10s04.html

those variables are fairly standard and lots of programs use them.  But I
don't know if other shells go out of their way to maintain consistancy
with the current terminal size on terminal resizing.

If you want to get at the environment variables, take a look at the
'os.environ' dictionary:

    http://www.python.org/doc/lib/os-procinfo.html#l2h-1508


Alternatively, if you're on Unix, the 'curses' module will get you the
information you want.

    http://www.python.org/doc/lib/module-curses.html

On Windows, it looks like you can use the following cookbook recipe:

    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440694



_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to