How to Change the Name of a Pygame window?

I am trying to change the name of a pygame window from "Pygame Window" to "test caption". I have tried:

pygame.display.set_caption('test caption')

But I don't think it is the right script.


Refer to http://www.pygame.org/docs/ref/display.html#pygame.display.set_caption:

set_caption(title, icontitle=None) -> None

If the display has a window title, this function will change the name on the window. Some systems support an alternate shorter title to be used for minimized displays.

Your usage was correct, so there must be another issue. Either your window is initialized incorrectly, or it isn't even initialized at all. Contributing your code would be helpful.


Call it after init().

pygame.init()
pygame.display.set_caption('test caption')