leejohnson
Posts: 43
Joined: Sun Sep 28, 2014 7:01 pm

gui button to next screen

Thu Dec 11, 2014 10:31 am

hello

i have tried getting my head round to make a simple touchscreen button using an picture (next) but going round in circle, tried using the lapse tourch as david uses pygame.

i am using python and pygame

what i want is 2 icon pictures are on mainscreen 1. icon 1 when pressed (go to mainscreen 0) icon 2 when pressed (go to mainscreen 2).

i think i need to define what a button is and then on each screen in the main loop say what action to take but i getting stuck on

can anyone drum up some code for me please so i can try and add it in to my script .

leejohnson
Posts: 43
Joined: Sun Sep 28, 2014 7:01 pm

Re: gui button to next screen

Fri Dec 12, 2014 10:03 am

sorry forgot to put script. i do have some script, i want the users button to go to the users page, settings to settings page and over ride ideally to trigger a GPIO relay please help me overcome my challedge

Code: Select all

#! /usr/bin/env python
import pygame, sys
from pygame.locals import *

pygame.init()

screen3 = pygame.display.set_mode((320,240)) #screen size

white = 255,255,255 #colour of screen

override = pygame.image.load("icons/override.png")# button images
users = pygame.image.load("icons/users.png")
changepin = pygame.image.load("icons/changepin.png")
settings = pygame.image.load("icons/settings.png")

screen3.fill(white)
screen3.blit(override,(5,10))# button position
screen3.blit(users,(165,10))
screen3.blit(changepin,(5,120))
screen3.blit(settings,(165,120))

pygame.display.flip()

while True : #main loop
   for event in pygame.event.get() :
      if event.type == QUIT :
         pygame.quit()
         sys.exit()

Return to “Python”