Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard events in pygame program run from spyder sent to terminal not program #4077

Open
pvince99 opened this issue Jan 30, 2017 · 9 comments

Comments

@pvince99
Copy link

pvince99 commented Jan 30, 2017

Description of your problem

I was using spyder ( version 2.3.4 ) to write and run a pygame/opengl program that handles both mouse and keyboard interactions.
When run from Spyder the program's window successfully captures mouse actions, keyboard events however are not captured and disappear (don't appear in the console window).
I am forced to use IDLE, manifestly unsatisfactory as an IDE, which does its thing successfully.

What steps will reproduce the problem?

  1. run the program as follows a) from spyder; b) from IDLE

What is the expected output? What do you see instead?
Expected output from spyder:
LEFT
276
KEYUP
...etc...
got MOUSEBUTTONDOWN

Actual output:
got MOUSEBUTTONDOWN
...etc...
quitting

Please provide any additional information below

import pygame, sys
from pygame.locals import *

pygame.init()
display = pygame.display.set_mode((500,500))

while True:
     pygame.display.update()
     events = pygame.event.get()
     for event in events:
         if event.type == QUIT:
             print('quitting')
             pygame.quit()
             sys.exit()
         else:
             if event.type == KEYDOWN:
                 if event.key == K_ESCAPE:
                     print ("ESCAPE")
                     pygame.quit()
                     sys.exit()
                 if event.key == K_LEFT:
                     print ("LEFT")
                 if event.key == K_RIGHT:
                     print ("RIGHT")
                 else:
                    print (event.key)
             if event.type == KEYUP:
                 print('KEYUP')
             if event.type == pygame.MOUSEBUTTONDOWN:
                 print('got MOUSEBUTTONDOWN')

Versions and main components

  • Spyder Version: 2.3.4
  • Python Version: 3.4.5
  • Operating system: OSX 10.10.3

Dependencies

pgame.version: 1.9.2a0

Please go to the menu entry Help > Optional Dependencies (or
Help > Dependencies), press the button Copy to clipboard
and paste the contents below:

@ccordoba12
Copy link
Member

Have you tried to change the run settings of your file (with F6) and run it in an external interpreter?

@pvince99
Copy link
Author

pvince99 commented Jan 31, 2017 via email

@ccordoba12 ccordoba12 added this to the v3.2 milestone Jan 31, 2017
@ccordoba12
Copy link
Member

I forgot we haven't implemented that functionality for macOS, sorry. We'll try to work on this for Spyder 3.2, to be released during the summer.

@ccordoba12 ccordoba12 modified the milestones: v3.2, v3.3 Feb 14, 2017
@ccordoba12 ccordoba12 modified the milestones: v4.0beta2, v4.0beta3 Aug 13, 2017
@pvince99
Copy link
Author

pvince99 commented Jun 25, 2018 via email

@ccordoba12
Copy link
Member

No, we haven't, sorry.

@ccordoba12 ccordoba12 modified the milestones: v4.0betaX, v3.3.1 Jun 25, 2018
@ccordoba12 ccordoba12 modified the milestones: v3.3.1, v3.3.2 Jul 14, 2018
@ccordoba12 ccordoba12 modified the milestones: v3.3.2, v3.3.3 Aug 18, 2018
@ccordoba12 ccordoba12 modified the milestones: v3.3.3, not sorted Jan 7, 2019
@goanpeca
Copy link
Member

goanpeca commented May 5, 2020

It appears that this is still not implemented on MacOS (High Sierra).

It is now implemented

@goanpeca goanpeca closed this as completed May 5, 2020
@pvince99
Copy link
Author

pvince99 commented May 6, 2020

No, it's not - running Spyder 4.0.1.
Same problem as first raised.

@ccordoba12 ccordoba12 reopened this May 6, 2020
@ccordoba12 ccordoba12 modified the milestones: not sorted, important May 6, 2020
@ccordoba12
Copy link
Member

@pvince99, we don't know how to fix this, sorry.

@gorkemer
Copy link

gorkemer commented Dec 1, 2021

running it in an external interpreter (for psychopy package) allowed me to interact with the events. Thank you @ccordoba12 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants