Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to accept text input from a pygame GUI

I am working on a RPG game using Python and Pygame, and am trying to make a two-part GUI, including a lower part that is like the basic command line, and a top part that will show all graphical "action."

What I need to find out is a way to include both in a pygame window, instead of using a pygame window and terminal window. As well, are there any Pygame GUI toolkits that would be appropriate for this use?

Thanks All!

like image 947
Pip Avatar asked Jul 21 '13 21:07

Pip


2 Answers

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)

like image 99
The-IT Avatar answered Sep 17 '22 14:09

The-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.

like image 28
scohe001 Avatar answered Sep 19 '22 14:09

scohe001