getting terminal display size?

Joshua J. Kugler joshua at eeinternet.com
Mon Feb 26 19:59:45 EST 2007


jeff wrote:

> I don't really understand any of that; can you right me a function
> that'll return the size as a tuple?

Did you even *try* his code?  I ran this: 

import termios, fcntl, struct, sys

s = struct.pack("HHHH", 0, 0, 0, 0)
fd_stdout = sys.stdout.fileno()
x = fcntl.ioctl(fd_stdout, termios.TIOCGWINSZ, s)
print '(rows, cols, x pixels, y pixels) =',
print struct.unpack("HHHH", x)

And got this result:

(36, 96, 0, 0)

Looks like a tuple to me.  return 'return' instead of 'print' the result. 
We don't mind helping, but it's nice to know that the user has made some
attempt to understand what is going on before asking for free work to be
done.

j



-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com




More information about the Python-list mailing list