I'm implementing a code that shows up an image in fullscreen size, using PyGame. I have two screens in my setup, one monitor and the one of the laptop. When I run my code to show on the monitor all works fine, but when I try it on the laptop screen something crash, and only a black screen is shown. My code is as follows:
def open_window2(path, key):
# key dict
key_dict={'a':K_a, 'b':K_b, 'c':K_c, 'd':K_d, 'e':K_e, 'f':K_f,
'g':K_g, 'h':K_h, 'i':K_i, 'j':K_j, 'k':K_k, 'l':K_l,
'm':K_m, 'n':K_n, 'o':K_o, 'p':K_p, 'q':K_q, 'r':K_r,
's':K_s, 't':K_t, 'u':K_u, 'v':K_v, 'w':K_w, 'x':K_x,
'y':K_y, 'z':K_z}
pygame.init()
# get screen resolution
resolution = (pygame.display.Info().current_w, pygame.display.Info().current_h)
surface = pygame.display.set_mode(resolution, FULLSCREEN)
image = pygame.image.load(path)
image = pygame.transform.scale(image, resolution)
rect = image.get_rect(); rect.center = resolution[0]//2, resolution[1]//2
surface.blit(image, rect)
pygame.display.update()
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.KEYDOWN: #press-key events
if event.key == key_dict[key]: # if C key is pressed ...
running = False
pygame.quit()
When I set it to pygame.FULLSCREEN shows a black screen, but when I set it to pygame.RESIZABLE the image is shown.
What should I do to fix the black screen problem?