I have a raspberry pi with a touchscreen running raspbian, I'm hoping to have a Gui on the touchscreen that had a number keypad that when a correct input is entered a pin will output to a door latch or something. I have been over to make a Gui with a number on (by Python) it but i cant get several numbers to sit next to each other. any info will help on this thanks :) This is the code I used to try and place the buttons (you can see i just used a simple LED on/off button Gui and used it to see the placement of the buttons)
from Tkinter import *
import tkFont
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(40, GPIO.OUT)
GPIO.output(40, GPIO.LOW)
win = Tk()
myFont = tkFont.Font(family = 'Helvetica', size = 36, weight = 'bold')
def ledON():
print("LED button pressed")
if GPIO.input(40) :
GPIO.output(40,GPIO.LOW)
ledButton["text"] = "LED OFF"
else:
GPIO.output(40,GPIO.HIGH)
ledButton["text"] = "LED ON"
def exitProgram():
print("Exit Button pressed")
GPIO.cleanup()
win.quit()
win.title("LED GUI")
exitButton = Button(win, text = "1", font = myFont, command = ledON, height =2 , width = 8)
exitButton.pack(side = LEFT, anchor=NW, expand=YES)
ledButton = Button(win, text = "2", font = myFont, command = ledON, height = 2, width =8 )
ledButton.pack(side = TOP, anchor=CENTER, expand=YES)
ledButton = Button(win, text = "3", font = myFont, command = ledON, height = 2, width =8 )
ledButton.pack(side = RIGHT, anchor=NE, expand=YES)
ledButton = Button(win, text = "4", font = myFont, command = ledON, height = 2, width =8 )
ledButton.pack(side = TOP, anchor=W, expand=YES)
ledButton = Button(win, text = "5", font = myFont, command = ledON, height = 2, width =8 )
ledButton.pack(side = TOP, anchor=W, expand=YES)
ledButton = Button(win, text = "6", font = myFont, command = ledON, height = 2, width =8 )
ledButton.pack(side = TOP, anchor=W, expand=YES)
ledButton = Button(win, text = "7", font = myFont, command = ledON, height = 2, width =8 )
ledButton.pack(side = TOP, anchor=W, expand=YES)
ledButton = Button(win, text = "8", font = myFont, command = ledON, height = 2, width =8 )
ledButton.pack(side = TOP, anchor=W, expand=YES)
ledButton = Button(win, text = "9", font = myFont, command = ledON, height = 2, width =8 )
ledButton.pack(side = TOP, anchor=N, expand=YES)
ledButton = Button(win, text = "0", font = myFont, command = ledON, height = 2, width =8 )
ledButton.pack(side = TOP, anchor=NW, expand=YES)
mainloop()