r/PythonLearning • • Nov 01 '26

Help Request Not picking up input?

Post image

either that, im using the wrong dialect, or somn just doesnt work, i am trying to have an image change when T is pressed (unload old image when pressed and when not pressed load old image)

also using pygame, the first image loads, but nothing changes when T is pressed, yes i have also tested with print("")

any help would be nice!

12 Upvotes

10 comments sorted by

13

u/4675636b2e Nov 01 '26

Shouldn't everything after pygame.quit() indented by additional two tabs?

5

u/TheCarFamily Nov 01 '26

dude you saved me, thanks

1

u/Makakhan Nov 01 '26

Once you have accessed the events it is cleaned out. You are moving through the event log in the for loop and then stepping back for the if event.type but it is already empty. So either tab the if over so it’s part of the for loop or save the event log as a list first and move through it as needed for that dt.

1

u/Makakhan Nov 01 '26 edited Nov 01 '26

On a second look, your if is actually outside the while loop entirely anyways? So it’s never making it to that point regardless.

0

u/TheCarFamily Nov 01 '26

what fix would you reccomend? and where is it located

1

u/Makakhan Nov 01 '26

Try taking everything for event.type == and all the way down and indent the whole thing till the if is nested inside the while loop, two tabs should do it.

1

u/TheCarFamily Nov 01 '26

thank you very much!

2

u/MarkoDahl54 Nov 01 '26

You need to use pygame.key.get_pressed() in your main loop and update the display with pygame.display.flip() after changing the image. Make sure your image blit happens before the display update.

1

u/Sleepybear842 Nov 01 '26

Without knowing the details of pygame class/obj, I can only say it appears your indentation is making your while loop end after the first event check. Remember whitespace is not trivial in python