I
I
ibr_982017-07-29 20:40:00
Python
ibr_98, 2017-07-29 20:40:00

Well, what's the matter?

Hello!
I'm learning pygame, and then a strange situation arose when I run the code, a black window comes out, I click on the cross of this window, and only then the real window comes out, what's the matter ??
here is the window:
e4ea2bf5e46e41449ae5c3d5e618c810.png
here is the real window after clicking on the cross of the black window:
868a3fe44ae54346b9c45aa7ef8243e2.png
here is the code itself:

import pygame
p = pygame
window = p.display.set_mode((400, 400))
p.display.set_caption('Hellow World')
screen = p.Surface((400, 400))

square = p.Surface((40, 40))
square.fill((0, 255, 0))

done = True
while done:
  for e in p.event.get():
    if e.type == p.QUIT:
      done = False
screen.fill((50, 50, 50))
screen.blit(square, (50, 100))
window.blit(screen, (0, 0))
p.display.flip()

Thank you

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Daniil Basmanov, 2017-07-30
@BasmanovDaniil

Shouldn't these lines be at the end?

done = True
while done:
  for e in p.event.get():
    if e.type == p.QUIT:
      done = False

S
Semyon Beloglazov, 2017-07-29
@Batlab

I understand that the first window is something like a console, no?
Try to save the file in the .pyw extension.
If it is the same, then look for the problem in the thematic sections.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question