I'm looking for an example on how to use curses.panel
to maintain overlapping windows.
Asked
Active
Viewed 8,608 times
5

Mark Lakata
- 19,989
- 5
- 106
- 123
-
1Looks like you already found some demos, but the py2.7 source had some [nice curses demos](http://hg.python.org/cpython/file/2.7/Demo/curses/). Particularly [this one](http://hg.python.org/cpython/file/61b6accbca9f/Demo/curses/ncurses.py) for panel manipulation. – kalhartt Jan 18 '14 at 15:42
1 Answers
12
I found this one here https://mail.python.org/pipermail/python-list/2001-April/105015.html . It moves one panel around the screen, below another panel.
from time import sleep
import curses, curses.panel
def make_panel(h,l, y,x, str):
win = curses.newwin(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):
try:
curses.curs_set(0)
except:
pass
stdscr.box()
stdscr.addstr(2, 2, "panels everywhere")
win1, panel1 = make_panel(10,12, 5,5, "Panel 1")
win2, panel2 = make_panel(10,12, 8,8, "Panel 2")
curses.panel.update_panels(); stdscr.refresh()
sleep(1)
panel1.top(); curses.panel.update_panels(); stdscr.refresh()
sleep(1)
for i in range(20):
panel2.move(8, 8+i)
curses.panel.update_panels(); stdscr.refresh()
sleep(0.1)
sleep(1)
if __name__ == '__main__':
curses.wrapper(test)

Thomas Dickey
- 51,086
- 7
- 70
- 105

Mark Lakata
- 19,989
- 5
- 106
- 123
-
2It would be nice if you credited the author or web site where you found this code. – Robᵩ Jan 16 '14 at 20:45
-
Umm why did you put a link to the web archived version? It's avaliable normally. – carefulnow1 Dec 16 '16 at 23:06
-
1That's where I found it. If you have a better link, please share it. – Mark Lakata Dec 16 '16 at 23:59