ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-list
python-list
Re: detect terminal width
by Michael Hudson other posts by this author
May 2 2001 10:09PM messages near this date
detect terminal width | Re: detect terminal width
"Bruce Edge" <bedge@[...].com>  writes:

>  Without using curses, can I detect terminal row/col settings from python?

Hmm, I posted this just a few weeks back:

This works for me:

def getwidth():
    return getheightwidth()[1]

# Eep!  this next should be made rather more portable (ie. fallback to
# env vars, then tigetstr("lines"), etc).
def getheightwidth():
    height, width = struct.unpack(
        "hhhh", ioctl(0, TERMIOS.TIOCGWINSZ ,"\000"*8))[0:2]
    return height, width

Cheers,
M.

-- 
  I'll write on my monitor fifty times 'I must not post self-indulgent
  wibble nobody is interested in to ucam.chat just because I'm bored
  and I can't find the bug I'm supposed to fix'.
                                            -- Steve Kitson, ucam.chat
-- 
http://mail.python.org/mailman/listinfo/python-list
Thread:
Bruce Edge
Michael Hudson
Bruce Edge

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved