Just open the window with a black screen. What is the problem?

import pygame, sys from pygame.locals import * pygame.init() background = pygame.image.load('1.jpg') screen = pygame.display.set_mode(background.get_size()) screen.blit(background, (0,0)) pygame.display.set_caption("Dinahoy") mainLoop = True while mainLoop: for event in pygame.event.get(): if event.type == QUIT: mainLoop = False 

    3 answers 3

    In minelup forgot to add the screen surface redraw function pygame.display.flip . Without it, everything is calculated at each iteration of the cycle, but nothing is displayed on the screen surface. It will look like this:

     import pygame, sys from pygame.locals import * pygame.init() background = pygame.image.load('1.jpg') screen = pygame.display.set_mode(background.get_size()) screen.blit(background, (0,0)) pygame.display.set_caption("Dinahoy") mainLoop = True while mainLoop: for event in pygame.event.get(): if event.type == QUIT: mainLoop = False pygame.display.flip() 

    Read more in the official documentation . Well, this is also explained in the first lesson there.

       import pygame, sys from pygame.locals import * pygame.init() background = pygame.image.load('1.jpg') print(background.get_size()) screen = pygame.display.set_mode(background.get_size()) screen.blit(background, (0, 0)) pygame.display.set_caption("Dinahoy") mainLoop = True while mainLoop: for event in pygame.event.get(): if event.type == QUIT: mainLoop = False pygame.display.flip() 

        Because images need to be drawn in the main loop. For you have drawn a picture, and then update the screen, and do not draw it again.