admin 管理员组文章数量: 1086019
With this example
#!/usr/bin/env python3
import curses
def repaint(stdscr,flog,wlog):
flog.clear()
wlog.clear()
# It seems flog and wlog autoresizing magicaly
# flog.resize(curses.LINES, curses.COLS)
# wlog.resize(curses.LINES-2, curses.COLS -2)
flog.box()
flog.refresh()
wlog.refresh()
def main(stdscr):
curses.curs_set(0)
stdscr.nodelay(True)
stdscr.keypad(True)
stdscr.refresh()
flog = curses.newwin(curses.LINES, curses.COLS, 0, 0)
wlog= flog.derwin(curses.LINES-2, curses.COLS - 2, 1, 1)
wlog.scrollok(True)
repaint(stdscr,flog,wlog)
wlog.addstr("Init application\n")
wlog.refresh()
finish = False
while not finish:
try:
key = stdscr.getch()
if key != -1:
if key == 113 or key == 81:
finish = True
elif key == curses.KEY_RESIZE:
curses.update_lines_cols()
repaint(stdscr,flog,wlog)
wlog.addstr("Resize\n")
wlog.refresh()
except curses.error:
pass
except Exception :
pass
if __name__ == "__main__":
curses.wrapper(main)
- When terminal window shrinks horizontally, the box and message are not showed.
- When terminal window is enlarged horizontally, the box and message are showed but right vertical line is missing
- When terminal window shrinks vertically, the box and message are showed but horizontal bottom line is missing
- When terminal window is enlarged vertically, all run as expected.
Is there another way to refresh the screen?
本文标签: Python curses refresh issues when resizing terminalStack Overflow
版权声明:本文标题:Python curses refresh issues when resizing terminal - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744055976a2525855.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论