I have a Raspberry Pi, and I want to get PyGame to display output on the attached 7" touchscreen, no matter how I launch the script to do this.
If I launch it from a terminal shell while using the 7" screen, it works.
If I launch it using an SSH session, I get a "pygame.error: Unable to open a console terminal" from pygame.display.init().
If I launch it from a terminal shell in a VNC session, it displays in the VNC display.
Here's relevant part of the script:
import pygame import os
os.environ['SDL_VIDEODRIVER'] = 'fbcon' os.environ["SDL_FBDEV"] = "/dev/fb0"
pygame.init()
pygame.display.init()
So far, the only way I can get this to work is to launch the script with:
DISPLAY=:0 python pygame_example.py
It seems that setting the os.environ values in the script has no effect whatsoever.
What is the correct way to do this?
Daniele