1
votes

The following code is being looped - is in a loop - but when 'inputStr' changes, the display does not. Printing inputStr yields the expected results, though.

defFnt = pygame.font.Font("CP437.ttf", 72)
txtToRndr = defFnt.render(inputStr,False, (0,0,0))
disp.blit(txtToRndr, (100,300))

Download link; http://www.mediafire.com/download/a4hp9wgojxgiao9/functGroup.rar

3
This looks correct . . . ish so far. Need more code to be sure. - imallett
Added some more code. - Charles Noon
Ack; I meant pertaining to rendering (you already said you had checked that the string is changing). - imallett
Oh, sorry. What else it there to the rendering? (besides perhaps the .flip and the declaration of disp as my surface) I could just give you the whole dir if you want. (it's a small project - only a couple of hours worth) - Charles Noon
I'd like to see the program's topology: the main loop and the render function. As a backup, maybe just FTP that dir. I'll take a look. - imallett

3 Answers

1
votes

If you print inputStr right before its rendered it prints for a bit then stops, meaning it isnt getting rendered after a certain point, Which i think is because this condition:

if (16-len(Gnots))>0:

it must be coming out false therefore the code to render the new text isnt being executed:

if you print Gnots after the condition, it prints it until its length is 16 items than stops change the number 16 in the condition to say 1000 as a test than try typing and the text changes

0
votes

Your code needs refactoring. As the other answer says, the main problem is that if-block (try changing it to if True:.

I would recommend capping the framerate but drawing every frame unconditionally, as this is simpler and more robust. You're also not clearing the screen each frame, and PyGame has nice key tokens (e.g. pygame.K_ESCAPE) which you should use instead of numbers. You're also loading the font each time you draw; you only need to do so once, at the top of your program.

Here's my PyGame basecode, which shows some of these best practices. In the draw() function, you'd add your fill call to clear the screen, and then all of your rendering code.

0
votes

I can suggest the following after encountering similar issue.

  1. Try updating the screen with your text by adding following line after your code: pygame.display.update()

  2. The issue of text not updating on screen was coming in my case as I was trying to take input from terminal and then updating in on pygame screen.