I need an example of overlapping curses windows using panels in python

做~自己de王妃 提交于 2019-12-06 11:59:15
Mark Lakata

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)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!