[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

get the terminal's size

Hi Cameron,

> My cs.tty module (on PyPI) has a ttysize function:
>   https://pypi.org/project/cs.tty/
> which just parses the output of the stty command.

> If you don't want the cs.tty module, the ttysize code is just this:
>     WinSize = namedtuple('WinSize', 'rows columns')
>     def ttysize(fd):
>       ''' Return a (rows, columns) tuple for the specified file
>       descriptor.
> [...]

Fine, indeed ! I've installed cs.ttyy.

I just don't understand the reason why it takes "fd" as an argument.
I tried : P = Popen(['stty', '-a'], stdout=subprocess.PIPE, 
universal_newlines=True) and it runs fine too, so the output seems not 
really related to that fd.

Btw I did not know about namedtuple, thanks for that too.

> Hope this helps.