Прошу прощения, если вопрос откровенно нубский.
На базе Raspberry pi написал хотел создать простую программу, позволяющую при нажатии на определенную клавишу клавиатуры зажигать светодиод, а с ее отпусканием - гасить. Казалось бы, все просто.
from tkinter import * import tkinter.font import RPi.GPIO as GPIO GPIO.setmode(GPIO.BOARD) GPIO.setup(37, GPIO.OUT) GPIO.output(37, GPIO.LOW) GPIO.setup(38, GPIO.OUT) GPIO.output(38, GPIO.LOW) GPIO.setup(36, GPIO.OUT) GPIO.output(36, GPIO.LOW) win = Tk() myFont = tkinter.font.Font(family = 'Helvetica', size = 26, weight = 'bold') def ledON(self): print("LED button pressed") GPIO.output(37,GPIO.HIGH) ledButton["text"] = "LED OFF" def ledON3(self): print("LED button nopressed") GPIO.output(37,GPIO.LOW) ledButton["text"] = "LED ON" def ledON1(self): print("LED button1 pressed") GPIO.output(38,GPIO.HIGH) ledButton1["text"] = "LED1 OFF" def ledON4(self): print("LED button1 nopressed") GPIO.output(38,GPIO.LOW) ledButton1["text"] = "LED1 ON" def ledON2(self): print("LED button2 pressed") GPIO.output(36,GPIO.HIGH) ledButton2["text"] = "LED2 OFF" def ledON5(self): print("LED button2 nopressed") GPIO.output(36,GPIO.LOW) ledButton2["text"] = "LED2 ON" def exitProgram(self): print("Exit Button pressed") GPIO.cleanup() win.quit() win.title("First GUI") win.geometry('800x480') exitButton = Button(win, text = "Exit", font = myFont, command = exitProgram, height =2 , width = 6) exitButton.pack(side = BOTTOM) ledButton = Button(win, text = "LED ON", font = myFont, command = ledON, height = 2, width = 6 ) ledButton.pack( side = RIGHT , padx = 10 , pady = 10 , ipadx = 10 , ipady = 10 ) ledButton1 = Button(win, text = "LED ON1", font = myFont, command = ledON1, height = 2, width = 6 ) ledButton1.pack( side = LEFT, padx = 10 , pady = 10 , ipadx = 10 , ipady = 10 ) ledButton2 = Button(win, text = "LED ON2", font = myFont, command = ledON2, height = 2, width = 6 ) ledButton2.pack() win.bind('i', ledON2 ) win.bind('j', ledON1 ) win.bind('l', ledON ) win.bind('k', exitProgram ) win.bind('<KeyRelease-l>', ledON3 ) win.bind('<KeyRelease-j>', ledON4 ) win.bind('<KeyRelease-i>', ledON5 ) mainloop()
Прошу помощи уважаемых гуро