概述
用户输入
while True:
c = stdscr.getch() # 返回按下的键的ascii码的值,整数型
if c == ord('p'):
PrintDocument()
elif c == ord('q'):
break # 退出循环
elif c == curses.KEY_HOME:
x = y = 0
显示文字
addstr()方法将Python字符串或bytestring作为要显示的值。 字节串的内容按原样发送到终端。 使用窗口encoding属性的值将字符串编码为字节。
addch()方法接受一个字符,该字符可以是长度为1的字符串,长度为1的字节字符串或整数。
curses.wrapper()
import surses, time
def main(stdscr):
while True:
stdscr.clear() # 清除屏幕
ch = stdscr.getch() # 获取字符输入
if ch == ord('p'):
stdscr.addstr('hello worldn')
elif ch == ord('q'):
break
stdscr.refresh() # 更新屏幕
time.sleep(1)
curses.wrapper(main)
**注意:**curses是默认先y后x,和其他屏幕的先x后y不一样。
最后
以上就是爱听歌季节为你收集整理的curses的使用 python用户输入显示文字curses.wrapper()的全部内容,希望文章能够帮你解决curses的使用 python用户输入显示文字curses.wrapper()所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复