1

I am using a small 2.4" touchscreen with a resolution of 320x240 and I am working with pygame to create a GUI. Strangely I am not recording any mouse click between y position 26 and 35.

The problem is not caused by the touchscreen itself. The raspbian desktop works fine. Only with pygame if have this problem. It does not matter if I use the mouse directly, via VNC or the touchscreen.

missing

import pygame
import os
import time


pygame.init()
screen = pygame.display.set_mode((320, 240), pygame.FULLSCREEN)
pygame.mixer.init()

black = pygame.Color(  0,   0,   0)
red   = pygame.Color(255,   0,   0)

screen.fill(black)
pygame.display.update()

running = True
while(running):
    for event in pygame.event.get():
        if event.type is pygame.KEYDOWN:
            if event.key == pygame.K_RETURN:
                running = False
        elif event.type is pygame.MOUSEBUTTONDOWN:
            pygame.draw.circle(screen, red, event.pos, 3)
            pygame.display.update()

    time.sleep(0.1)

pygame.image.save(screen, 'touch.png')
qubit
  • 129
  • 2
  • Works fine on my 1080p screen. – CoderMike Jul 20 '19 at 10:06
  • Are you sure? Pixels 26 to 35 is a really thin strip on 1080 pixels. I just realized its also happening on a 3.5" touchscreen from Adafruit. This one has a y resolution of 480. I did not realize until now it because it is so thin. – qubit Jul 20 '19 at 13:02
  • Yes, i'm sure. The screen is correctly created at 320,240 and I don't see any gaps. https://i.imgur.com/3vgzzOL.png – CoderMike Jul 20 '19 at 13:55
  • I'm using Raspbian Buster, Python3.7.3, PyGame 1.9.4.post1 – CoderMike Jul 20 '19 at 14:02
  • Thank you very much for the information. I am running exactly the same system. I just started a second vnc server and run it on there..... it works fine (but still has the gap on the front touch screen) – qubit Jul 20 '19 at 18:50

0 Answers0