pygame/python中的文本输入框 [英] Text input box in pygame/python
问题描述
我正在使用pygame/python开发一个RPG.我做了一个字符.创建者,可让您自定义播放器.现在,我正在寻找一种提示在屏幕上输入名称的方法.我不想让它成为一个盒子,只是打印用户在特定区域中输入的内容(参见图片). 感谢您的帮助.
I am working on an RPG in pygame/python. I have made a char. creator that allows you to customize the player. Now I am looking for a way to prompt for a name on-screen. I don't want it to make a box, just print what the user is typing in a specific area (see picture). Thanks for help.
http://ubuntuone.com/3HdzOKroopUEf1YxqNnbFM < -----图片(仅显示为蓝色链接)
http://ubuntuone.com/3HdzOKroopUEf1YxqNnbFM <-----Picture (only looks blue through the link)
推荐答案
您可以捕获事件,如果event.type == KEYDOWN,则检查event.key以获取用户按下的键.然后,您可以将其添加到文本变量中并在屏幕上显示.
You can capture the events and if event.type == KEYDOWN, then check for event.key to get which key is the user pressing. Then you can add it to a text variable and show it on the screen.
这篇关于pygame/python中的文本输入框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!