Curses.ADDSTR不会输出到控制台
我最近通过py -m pip安装Windows-curses
在高架命令提示符中运行的Windows-curses
模块在我的计算机上安装了模块。
我编写了以下代码以测试它是否正常工作。如果正确运行,则应将字符串打印到控制台。但是,什么都没有发生 - 即终端保持空白,没有显示字符。
#initialise curses
import curses
stdscr=curses.initscr()
curses.noecho()
curses.cbreak()
stdscr.keypad(True)
#write text
stdscr.addstr(0,0,'test')
#loop program so the terminal does not close
while 1:
pass
我尝试将addstr
拨打到While循环中,并使用包装器
,但都没有解决问题。 发生了什么,我该如何解决这个问题?提前致谢!
I've recently installed the windows-curses
module on my machine, via py -m pip install windows-curses
run in an elevated command prompt.
I wrote the following code to test if it was working correctly. If it runs correctly, it should print the string test
to the console. However, nothing happens - i.e the terminal remains blank, with no characters displayed.
#initialise curses
import curses
stdscr=curses.initscr()
curses.noecho()
curses.cbreak()
stdscr.keypad(True)
#write text
stdscr.addstr(0,0,'test')
#loop program so the terminal does not close
while 1:
pass
I've tried putting the addstr
call inside the while loop, as well as using the wrapper
, but neither resolved the issue.
What's going on, and how can I resolve this issue? Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须刷新屏幕。当您要求输入时,例如
window.getch()
或调用window.refresh()
直接进行物理屏幕更新。尝试此片段:
You have to refresh the screen. Curses does a physical screen update when you ask for input, e.g. with
window.getch()
or callwindow.refresh()
directly.Try this snippet: