[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] font/text in pygame
On Tue, Apr 26, 2005 at 03:57:51PM -0700, D. Hartley wrote:
> So with pygames, if I want to display text on the graphics window, I
> can set the font and size and so on, and set what I want my text to
> be. But if I wanted python to grab that text from a list, say, how
> would I do that? I can do it in the print command, as follows:
>
> for score, name in high_scores:
> slip = 30 - len(name)
> slip_amt = slip*" "
> prefix = 5*" "
> print prefix,name,slip_amt,score
>
> (slip et al. is spacing stuff - not the prettiest code to do it, but it works)
>
> But in any case, font/text will only take strings - i cant pass in a
> list, or an index to an item in a list (which is, in this case, a
> tuple), and since the items in the list will be changed and updated
> obviously i cant just type in the items as strings myself.
>
> any ideas? does this question even make sense the way it's worded?
> It's a last-ditch effort to get my high score list onto the graphics
> window before i have to abandon it :)
>
> Thanks!
> ~Denise
You are going about this wrong. What you need to understand about
displaying text in pygame is that it works nothing at all like
displaying text in a console. In a console, you print text, and it goes
to the cursor position, but within a pygame window, you render text to a
surface, which you then draw on the screen. You aren't really working
with text, you are working with a picture of text.
---
Bob the Hamster