I am trying to make a little piece of software to display how many times a button is pressed. I made the gui work, the button input works, but I can't figure out how to make the counter update each time I press the button, root.update() didn't work. Code:
import RPi.GPIO as GPIO
import time
import os
import Tkinter as tk
from Tkinter import *
root = tk.Tk()
root.overrideredirect(True)
root.overrideredirect(False)
root.attributes('-fullscreen',True)
root.configure(background='black')
root.configure(cursor="none")
buttonPin = 21
GPIO.setmode(GPIO.BCM)
GPIO.setup(buttonPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
Counter = 69
w = Label(root, text=Counter, fg="white", bg="black", font=("Helvetica",80))
w.pack()
w.place(relx=0.5, rely=0.5, anchor=CENTER)
last_state = True
input_state = True
root.mainloop()
while True:
input_state = GPIO.input(buttonPin)
if (not input_state):
Counter += 1
print(Counter)
time.sleep(0.3)