How to accept text input from a pygame GUI

时光总嘲笑我的痴心妄想 提交于 2019-12-05 11:40:46

May I suggest using ezText instead? It's a cool way to add text inupt bars to pygame. I used it before my self, and It's really easy to use.

http://www.pygame.org/project-EzText-920-.html

(feel free to leave a comment if you want help using it, although everything you need to know is in the example.py that comes with it)

Take a look here (http://wiki.python.org/moin/PythonGameLibraries) for a whole list of ToolKits for both Pygame and Pyglet. Albow (http://www.cosc.canterbury.ac.nz/greg.ewing/python/Albow/) has worked well for me in the past.

The easiest way to accomplish what you're talking about would be to make two Surfaces, one for each part of the interface, and then constantly update them in separate modules to finally blit them every frame. That way your main module can be simplified to something like:

import action_gui
import cl_gui
import pygame

pygame.init()
MAIN_SURF = pygame.display.set_mode((x, y))
pygame.display.set_caption('My Game')

while (True):
    action_surf = action_gui.update()
    cl_surf = cl_gui.update()
    MAIN_SURF.blit(action_surf, my_position_1)
    MAIN_SURF.blit(cl_surf, my_position_2)

Best of luck.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!