<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Oleg Broytmann wrote:
<blockquote TYPE=CITE>Hello!
<p> Is there anyone who program with curses these days? These
days are full
<br>of GUI and CGIs, but as they included curses.panel as a new module
in
<br>curses, I think there are curses users. I want to learn curses.
<br> Yes, curses. If I would want to write a GUI - I'd do it
with graphical
<br>toolkit, probably wxWindows. But now I want to learn curses.
<br> I am newbie in curses programming. I never wrote curses
programs in C,
<br>and I want to learn curses by programming in Python.
<p> Ok, I wrote few very simple program - they work. So I started
to write
<br>more complex program... and stumbled upon panels. I cannot use panels
-
<br>cannot change stack order, e.g. Can anyone help?
<p>from time import sleep
<br>import curses, curses.panel
<p>def make_panel(stdscr, h,l, y,x, str):
<br> win = stdscr.subwin(h,l, y,x)
<br> win.erase()
<br> win.box()
<br> win.addstr(2, 2, str)
<p> panel = curses.panel.new_panel(win)
<br> return win, panel
<p>def test(stdscr):
<br> curses.curs_set(0)
<br> stdscr.box()
<br> stdscr.addstr(2, 2, "panels everywhere")
<br> win1, panel1 = make_panel(stdscr, 10,12, 5,5, "Panel 1")
<br> win2, panel2 = make_panel(stdscr, 10,12, 8,8, "Panel 2")
<br> stdscr.refresh()
<br> sleep(1)
<p> panel1.top(); curses.panel.update_panels()
<br> stdscr.refresh()
<br> sleep(1) # This DOES NOT work! panel1 is still bottom
panel :(((
<p> for i in range(50): # This works... partially... panel1
is not updated :(((
<br> panel2.move(8, 8+i)
<br> stdscr.refresh()
<br> sleep(0.1)
<p> sleep(1)
<p>if __name__ == '__main__':
<br> curses.wrapper(test)
<p>Oleg.
<br>----
<br> Oleg Broytmann
<a href="http://phd.pp.ru/">http://phd.pp.ru/</a>
phd@phd.pp.ru
<br> Programmers
don't die, they just GOSUB without RETURN.</blockquote>
<p>Instead of using stdscr.subwin() you need to make a new window using
curses.newwin() and the same arguments get what you want. You also
need an extra curses.panel.update_panels() inside the for loop that moves
panel2.
<p>Jake</html>