I'm trying to run a Pygame app without using X. I have a Raspberry Pi 3 with raspbian Jessie installed with very few modifications.

The script I'm trying to run is the following:

import sys, pygame


c1 = (255,0,255)
c2 = (0,255,0)

screen = pygame.display.set_mode((1360,768), pygame.FULLSCREEN)

rect = pygame.Rect(50,50,50,50)

clock = pygame.time.Clock()

while 1:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:

        if event.type == pygame.KEYDOWN:

    pygame.draw.rect(screen,c2, rect)


I have confirmed it works under the desktop environment and with X11, by adding it in .xinitrc. I have succeded in running it "bare" from the command line (provided the resolution is the right one for the screen).

However, I would like to run with a 3.5 inches touch screen as display (https://www.amazon.it/gp/product/B075JFT9SF/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1). It works as well before setting up the touch screen drivers: after that, any attempt to use Pygame result in a black screen and a stuck system. Though I can access via ssh and reboot, any other input is ignored.

I've googled for a couple of days now, but I don't seem to be able to find anything useful. Most results are confused and confusing, citing bugs with pygame and Jessie, and I feel like I'm missing something.

Does anyone know if this is supposed to work, or if I'm skipping some steps?

  • 1
    the game uses X11 ... why do you expect it to work without X11 ?
    – jsotola
    Feb 25 '18 at 23:04
  • Pygame does not uses X11, and it works without it when using a "normal" monitor. My question is why it doesn't with the specified TFT screen.
    – Maldus
    Feb 26 '18 at 5:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.