I'm trying to use Pygame and Python 2.7 to control a Roomba connected to a Raspberry Pi. I'm connected to the Pi through Putty and controlling it through the Putty console. The problem I'm having is that I can't get a Pygame display to show, and Pygame keyboard input only works when the Pygame screen has focus. There's just no window opened when the code runs and Putty's console just sits there. Is there a way to open the Pygame window this way?
I have working code that doesn't use Pygame, but it uses a getch for input so you can only toggle movement through incoming characters, you can't get it to stop moving when you stop holding down the key.
Here is my basic code where I'm just trying to get Pygame to do ANYTHING when I press a key:
import pygame, sys
from pygame.locals import *
pygame.init()
screen = pygame.display.set_mode((600, 400))
pygame.display.flip()
while 1:
key=pygame.key.get_pressed()
if key[pygame.K_w]:print'w'
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
elif event.type == KEYDOWN and event.key == K_ESCAPE:
sys.exit()
elif event.type == KEYDOWN and event.key == K_s:
print's'