问题描述
限时送ChatGPT账号..伙计们,我正在研究 python 诅咒,我的初始窗口带有 initscr() 并且我创建了几个新窗口来重叠它,我想知道我是否可以删除这些窗口并恢复标准屏幕无需重新填充它.有办法吗?我也可以问是否有人可以告诉我窗口、子窗口、垫和子垫之间的区别.
Hell-o guys, I'm working on python curses and I have my initial window with initscr() and 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? I can also ask if someone can tell me the difference between a window, subwindow, pad and sub pad.
我有这个代码:
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.
推荐答案
这,例如,应该工作:
import curses
def fillwin(w, c):
y, x = w.getmaxyx()
s = c * (x - 1)
for l in range(y):
w.addstr(l, 0, s)
def main(stdscr):
fillwin(stdscr, 'S')
stdscr.refresh()
stdscr.getch()
newwin=curses.newwin(10,20,5,5)
fillwin(newwin, 'w')
newwin.touchwin()
newwin.refresh()
newwin.getch()
del newwin
stdscr.touchwin()
stdscr.refresh()
stdscr.getch()
curses.wrapper(main)
这用'S'填充终端;在任何按键时,它都会用w"填充窗口;在下一次击键时,它会移除窗口并再次显示 stdscr,因此它再次全部为-'S';在下一次击键时,脚本结束,终端恢复正常.这不适合你吗?或者你真的想要一些不同的东西......?
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...?
这篇关于如何在python中删除一个诅咒窗口并恢复背景窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论