>>>>> lsk040365 <lkenne...@gmail.com> (l) wrote:

>l> Can you provide me with some sort of example possibly--I have been
>l> fighting this for a while and I wouldn't be using curses but I have
>l> designed the program with the extended ascii characters thereby making
>l> a nice UI...?

Nice UI???? This is so 70's :=)

import curses, os
screen = curses.initscr()

height, width = screen.getmaxyx()
print height, width

# popen is deprecated: better switch to subprocess.Popen
ls = os.popen("ls -l")
while True:
    screen.clear()
    screen.addstr(0, 0, "DIRECTORY LISTING")

    # display as many lines as will fit on the screen
    for i in range(1, height-1):
        line = ls.readline()
        if not line: break
        screen.addstr(i, 0, line.rstrip())

    if line: # we have more to expect
        screen.addstr(height-1, 0, "PLEASE HIT RETURN FOR NEXT SCREEN OR q TO 
STOP")
        screen.refresh()
        key = screen.getkey()
        if key.lower() == 'q':
            break
    else: # end of listing reached
        screen.addstr(height-1, 0, "** END OF LISTING ** HIT RETURN")
        screen.refresh()
        screen.getkey()
        break
    
curses.endwin()
-- 
Piet van Oostrum <p...@cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: p...@vanoostrum.org
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to