5

I'm looking for an example on how to use curses.panel to maintain overlapping windows.

Mark Lakata
  • 19,989
  • 5
  • 106
  • 123
  • 1
    Looks 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 Answers1

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