Using text inputs in pygame Using text inputs in pygame tkinter tkinter

Using text inputs in pygame


I've tryed using Tk but the thing about using is it stops the whole pygame program when the Tk window pops up and its just not good

this is what i use Pygame InputBox its not the prettiest but it works great just download it and its really easy to use

just import inputbox

then do something like this:

inp = int(inputbox.ask(screen, 'Message')) #inp will equal whatever the input is

this is pretty much like raw_input but for pygame

its not the most aesthetically pleasing but im sure if you search around you can find maybe a nicer one


You can use a small library i'm making, just download it and use it.

To make a simple Text box try:

from GUI import *input_bow = InLineTextBox((0, 0), 200)  

You must give it at least a postion and the sizeThen in your input loop, update it :

for e in pygame.event.get():    input_box.update(e)

and at the end, render it :

input_box.render(screen)

You can get the text with input_box.text at any moment


I recommend using EzText. It's a great way to add text inputs into your pygame programs. I have personally used it my self and it is nice and easy and works with python 3.3.2.

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