addstr 延迟 Python Curses
addstr delay in Python Curses
我正在开发 AI,我正在使用 Curses,我希望能够添加一条消息,等待五秒钟,然后绘制另一条消息。
下面是我正在尝试修复的部分
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import curses
import time
screen = curses.initscr()
curses.noecho()
curses.curs_set(0)
screen.keypad(1)
screen.addstr("This is a Sample Curses Script\n\n")
screen.addstr("This is a Sample Curses Script\n\n")
time.sleep(5)
screen.addstr("This is a Sample Curses Script\n\n")
while True:
event = screen.getch()
if event == ord("q"): break
curses.endwin()
After you have put on the window what you want there, when you want the portion of the terminal covered by the window to be made to look like it, you must call refresh().
因此,更改您的代码:
import curses
import time
screen = curses.initscr()
curses.noecho()
curses.curs_set(0)
screen.keypad(1)
screen.addstr("This is a Sample Curses Script\n\n")
screen.addstr("This is a Sample Curses Script\n\n")
screen.refresh()
time.sleep(5)
screen.addstr("This is a Sample Curses Script\n\n")
screen.refresh()
while True:
event = screen.getch()
if event == ord("q"): break
curses.endwin()
我正在开发 AI,我正在使用 Curses,我希望能够添加一条消息,等待五秒钟,然后绘制另一条消息。
下面是我正在尝试修复的部分
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import curses
import time
screen = curses.initscr()
curses.noecho()
curses.curs_set(0)
screen.keypad(1)
screen.addstr("This is a Sample Curses Script\n\n")
screen.addstr("This is a Sample Curses Script\n\n")
time.sleep(5)
screen.addstr("This is a Sample Curses Script\n\n")
while True:
event = screen.getch()
if event == ord("q"): break
curses.endwin()
After you have put on the window what you want there, when you want the portion of the terminal covered by the window to be made to look like it, you must call refresh().
因此,更改您的代码:
import curses
import time
screen = curses.initscr()
curses.noecho()
curses.curs_set(0)
screen.keypad(1)
screen.addstr("This is a Sample Curses Script\n\n")
screen.addstr("This is a Sample Curses Script\n\n")
screen.refresh()
time.sleep(5)
screen.addstr("This is a Sample Curses Script\n\n")
screen.refresh()
while True:
event = screen.getch()
if event == ord("q"): break
curses.endwin()