1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] My python editor crashes on the first code I write with pygame [duplicate]

Discussão em 'Python' iniciado por Stack, Setembro 12, 2024.

  1. Stack

    Stack Membro Participativo

    I am starting off Python programming with a pygame tutorial.

    The tutorial tells me to write the below code:-

    import pygame

    pygame.init()

    screen = pygame.display.set_mode((800,400))

    and when I press enter after writing the above code, the code runs,

    and is supposed to produce a 800px by 400px window , closing it automatically shortly after.

    However, when I run this code, the window is produced but doesn't automatically close, so when I close it manually by clicking on the close button, the window crashes, closing the python editor along with itself.

    How can I solve this problem?

    I asked the chatGPT for solution and it gave me the below code to try:-

    import pygame

    pygame.init()

    screen = pygame.display.set_mode((800, 400))

    pygame.quit()

    However, the window still wouldn't close by itself, closing the whole python editor with it.

    Continue reading...

Compartilhe esta Página