79380656

Date: 2025-01-23 10:30:26
Score: 0.5
Natty:
Report link

I guess this code can do the job, not tested yet and not sure it's the simplest way :

from tkinter import *
from tkinter import ttk
import RPi.GPIO as GPIO

root = Tk()

Pin=10
GPIO.setmode(GPIO.BCM)
GPIO.setup(Pin, GPIO.IN)

def p():
  print('hello')

BUT_Quitter = ttk.Button ( root , text = "Quitter" , command = root.destroy )
BUT_Quitter.pack ( )
BUT_display = ttk.Button ( root , text = "Hello" , command = p )
BUT_display.pack ( )

def poll_for_data():
    data=GPIO.input(Pin)
    if data==1:
        BUT_display.invoke()
    root.after(100, poll_for_data)
    
root.after(100, poll_for_data)
 
root.mainloop ( )
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: bbd 666