如何在Python中删除诅咒窗口并恢复背景窗口?
我正在研究 pythoncurses,并且我有一个带有 initscr() 的初始窗口。然后我创建了几个新窗口来重叠它,我想知道是否可以删除这些窗口并恢复标准屏幕而无需重新填充它。有办法吗?有人能告诉我窗口、子窗口、垫和子垫之间的区别吗?
我有这个代码:
stdscr = curses.initscr()
####Then I fill it with random letters
stdscr.refresh()
newwin=curses.newwin(10,20,5,5)
newwin.touchwin()
newwin.refresh()
####I want to delete newwin here so that if I write stdscr.refresh() newwin won't appear
stdscr.touchwin()
stdscr.refresh()
####And here it should appear as if no window was created.
I'm working on python curses and I have an initial window with initscr(). Then I create several new windows to overlap it, I want to know if I can delete these windows and restore the standard screen without having to refill it. Is there a way? Could someone tell me the difference between a window, subwindow, pad and sub pad.
I have this code:
stdscr = curses.initscr()
####Then I fill it with random letters
stdscr.refresh()
newwin=curses.newwin(10,20,5,5)
newwin.touchwin()
newwin.refresh()
####I want to delete newwin here so that if I write stdscr.refresh() newwin won't appear
stdscr.touchwin()
stdscr.refresh()
####And here it should appear as if no window was created.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
例如,这应该有效:
这会用“S”填充终端;在任何按键处,它都会用“w”填充窗口;在下一次击键时,它会删除窗口并再次显示 stdscr,所以它又是全“S”;在下一次击键时,脚本结束并且终端恢复正常。这不适合你吗?或者你真的想要一些不同的东西......?
This, e.g, should work:
This fills the terminal with 'S'; at any keystoke, it fills the window with 'w'; at the next keystroke, it removes the window and show the stdscr again, so it's again all-'S'; at the next keystroke, the script ends and the terminal goes back to normal. Isn't this working for you? Or do you actually want something different...?