Computer Science Canada

getting input from user to display on pygame screen

Author:  shaon [ Thu Jan 31, 2008 10:12 pm ]
Post subject:  getting input from user to display on pygame screen

In python I know that in order to get text input from the user we can use raw_input or input(). However, these methods are a bit awkard when part of a program that uttilizes pygame. I'm trying to build a reader that stores the inputs internally, and so far I have one working by checking the event que for KEYUP. KEYUP however returns the values of the key being pressed numerically, and not in characters or text for that matter. The method key.name(num) returns a description of the key being pressed. This works for keys from a-z and 0-9 since the description for "a" is "a", however for such keys as space, key.name() gives back "space" even though what is needed is " ". So my question is does anybody know a built-in-function or method in pygame which converts numerical values returned from event.KEYUP or event.KEYDOWN into characters.

Author:  syntax_error [ Thu Jan 31, 2008 10:17 pm ]
Post subject:  Re: getting input from user to display on pygame screen

not totally sure here but look up casting? quick google search might help

Author:  McKenzie [ Sat Feb 02, 2008 9:35 am ]
Post subject:  RE:getting input from user to display on pygame screen

Ya shaon, it's simply chr.
e.g. x = chr(65)
x will have a value of 'A'


: