I'm using this bit of code in pycharm, but none of the print for events works(the quit, mouse button click or key pressing on keyboard)
Although I see the pygame window but the events doesn't work.
I also used the get() instead of wait() but still no luck.
any ideas?
import pygame
pygame.init()
screen = pygame.display.set_mode((800, 600))
while True:
event = pygame.event.wait()
if event.type == pygame.QUIT:
print('Quit')
if event.type == pygame.KEYDOWN:
print('Key Down')
print(event.key)
print(event.unicode)
if event.type == pygame.KEYUP:
print('Key Up')
print(event.key)
if event.type == pygame.MOUSEBUTTONDOWN:
print('Mouse Button Down')
print(event.pos)
print(event.button == pygame.BUTTON_RIGHT)
print(event.button == pygame.BUTTON_LEFT)
if event.type == pygame.MOUSEBUTTONUP:
print('Mouse Button Up')
print(event.pos)
print(event.button == pygame.BUTTON_RIGHT)
print(event.button == pygame.BUTTON_LEFT)
if event.type == pygame.MOUSEMOTION:
print('Mouse Motion')
print(event.pos)
print(event.rel)
UPDATE I found out that it's a problem with pycharm. when I run any code with pygame just a black pygame windows pop up, it doesn't run any other code(events, filling window with color ,...). Even the pygame window is not in dimensions that I've given.
Here another code example.
import pygame
pygame.init()
screen = pygame.display.set_mode((200, 200))
red = (255, 0, 0)
screen.fill(red)
pygame.display.update()
pygame.time.delay(10000)
when I run it in VS code:
and when I run it in pycharm :( :
also I'm defining the same Interpreter for both VS code and pycharm and I've already reinstalled pygame package.