curses.panel
Oleg Broytmann
phd at phd.fep.ru
Tue Apr 24 10:41:35 EDT 2001
Hello!
Is there anyone who program with curses these days? These days are full
of GUI and CGIs, but as they included curses.panel as a new module in
curses, I think there are curses users. I want to learn curses.
Yes, curses. If I would want to write a GUI - I'd do it with graphical
toolkit, probably wxWindows. But now I want to learn curses.
I am newbie in curses programming. I never wrote curses programs in C,
and I want to learn curses by programming in Python.
Ok, I wrote few very simple program - they work. So I started to write
more complex program... and stumbled upon panels. I cannot use panels -
cannot change stack order, e.g. Can anyone help?
from time import sleep
import curses, curses.panel
def make_panel(stdscr, h,l, y,x, str):
win = stdscr.subwin(h,l, y,x)
win.erase()
win.box()
win.addstr(2, 2, str)
panel = curses.panel.new_panel(win)
return win, panel
def test(stdscr):
curses.curs_set(0)
stdscr.box()
stdscr.addstr(2, 2, "panels everywhere")
win1, panel1 = make_panel(stdscr, 10,12, 5,5, "Panel 1")
win2, panel2 = make_panel(stdscr, 10,12, 8,8, "Panel 2")
stdscr.refresh()
sleep(1)
panel1.top(); curses.panel.update_panels()
stdscr.refresh()
sleep(1) # This DOES NOT work! panel1 is still bottom panel :(((
for i in range(50): # This works... partially... panel1 is not updated :(((
panel2.move(8, 8+i)
stdscr.refresh()
sleep(0.1)
sleep(1)
if __name__ == '__main__':
curses.wrapper(test)
Oleg.
----
Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru
Programmers don't die, they just GOSUB without RETURN.
More information about the Python-list
mailing list