Como excluo uma janela de maldição na janela Python e restaura a janela de fundo?

StackOverflow https://stackoverflow.com/questions/2575409

  •  24-09-2019
  •  | 
  •  

Pergunta

Hell-O pessoal, estou trabalhando em maldições de python e tenho minha janela inicial com initcr () e crio várias novas janelas para sobrepondê Reabasteça. Há algum jeito? Também posso perguntar se alguém pode me dizer a diferença entre uma janela, SubWindow, Pad e Sub Pad.

Eu tenho este código:

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.
Foi útil?

Solução

Isso, por exemplo, deve funcionar:

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)

Isso preenche o terminal com 's'; Em qualquer chave de chave, ele enche a janela com 'W'; Na próxima tecla, ele remove a janela e mostra o stdscr novamente, por isso é novamente tudo '; Na próxima tecla, o script termina e o terminal remonta ao normal. Isso não está funcionando para você? Ou você realmente quer algo diferente ...?

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top