J'ai une framboise pi avec un écran tactile fonctionnant raspbian, j'espère avoir un Gui sur l'écran tactile qui avait un clavier numérique que quand une entrée correcte est entré une broche sera sortie à un verrou de porte ou quelque chose. J'ai été sur le point de faire un Gui avec un numéro sur (par Python), mais je ne peux pas obtenir plusieurs numéros à s'asseoir les uns à côté des autres. Ceci est le code que j'ai utilisé pour essayer et placer les boutons (vous pouvez voir que je viens d'utiliser un simple bouton marche/arrêt LED Gui et utilisé pour voir le placement des boutons)Besoin d'un clavier Gui pour un écran tactile qui délivre une broche lorsque le code est correct
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()
montrer votre code - Qu'avez-vous utilisé - Tkinter, PyQt, wxPython ou quelque chose sa ? – furas
Je pense que son Tkinter – RedstoneMaina
vous pouvez attribuer à chaque fonction de bouton avec argument - ie. 'command = lambda: ledON (" 1 ")' et utilise 'def ledON (arg):' pour obtenir cet argument et se souvenir de la liste. De cette façon, vous pouvez obtenir votre code PIN. – furas