#GPIO # TKINTER
Verfasst: Mittwoch 25. März 2020, 09:12
Hallo Profis und Experte ; )
ich habe einen Problem beim GPIO-taster zu steuren ; beim Taster betätigen ( gpio.input(16)==1 ) soll ein TEXT auf dem GUI statusbar anzeigen, tut sich aber nichts
alle andern Funktionen ( ) sind Ok , ( ist das überhaup möglich ? alternative velleicht ?ich brauche eure Hilfe .... ) ( Vorschläge für das Code? andere Schreibweise ?)
Danke im Voraus
ich habe einen Problem beim GPIO-taster zu steuren ; beim Taster betätigen ( gpio.input(16)==1 ) soll ein TEXT auf dem GUI statusbar anzeigen, tut sich aber nichts
alle andern Funktionen ( ) sind Ok , ( ist das überhaup möglich ? alternative velleicht ?ich brauche eure Hilfe .... ) ( Vorschläge für das Code? andere Schreibweise ?)
Danke im Voraus
Code: Alles auswählen
import time as t
from tkinter import*
import threading
import RPi.GPIO as gpio
diff = 0
diff2 = 0
notaus1 = 0
notaus2= 0
gpio.setmode(gpio.BCM)
gpio.setwarnings(False)
''' INPUT definieren '''
gpio.setup(16, gpio.IN, pull_up_down = gpio.PUD_DOWN) #start
#_________________________destroy_Funktion()__________________
def on_closing():
window.destroy()
#_____________________________PROBLEM IST HIER----(Taster_Funktion())________________
def GPIO_TASTER () :
while gpio.input(16)== 1:
statusbar1["text"] ="Button gedrückt"
threading.Thread(target=Funktion_knopf).start()
#_____________________________stop_BUTTON______________________________
def stop ():
global notaus1
global notaus2
notaus1 = 1
notaus2 = 1
statusbar1["text"] ="STOP"
#" _________________________Start_Wischen_______________________________"
#---------------Knopf-----------------
def Start_wischen ():
global notaus1
global notaus2
notaus2 = 0.2
statusbar1["text"] ="Start_Wischen"
Wischen()
# -------------Function()-------------
def Wischen () :
if notaus1 != 0.1 :
def Run2 ():
global diff2
start_t2 = t.time()
while notaus2==0.2 and diff2 < 23 :
end_t2 =t.time()
diff_2 =int(end_t2 - start_t2)+1000
statusbar2["text"] = ("time_Wischen is :", diff_2)
threadd = threading.Thread(target=Run2).start()
#" _________________________ SENSOR-TEST_______________________________"
#---------------Knopf-----------------
def Start_SensorTest () :
global notaus1
global notaus2
notaus1 =0.1
statusbar1["text"] ="Start_Test"
Test()
# -------------Function()-------------
def Test ():
if notaus2 != 0.2 :
def Run():
global diff
start_t = t.time()
while notaus1 == 0.1 and diff < 15 :
end_t = t.time()
diff = int(end_t - start_t)
statusbar2["text"] = ("Test_time is :", diff)
thread = threading.Thread(target=Run).start()
#" _________________________ GUI_______________________________"
window = Tk()
window.title("GUI")
#outputs
statusbar1 = Label(window, text="auf start druecken", width=25,height =5, borderwidth=15 ,relief = SUNKEN)
statusbar1.grid(row= 6, column = 2)
statusbar2 = Label(window, text="Time", width=25,height =5, borderwidth=15 ,relief = SUNKEN)
statusbar2.grid(row= 7, column = 2)
# variable to store input
b1=Button(window, text="SensorTest",command =Start_SensorTest)
b1.grid(row=2, column = 2, padx= (100,5), pady=5)
b2=Button(window, text="Startwischen ",command = Start_wischen)
b2.grid(row=3, column = 2, padx= (100,5), pady=5)
b3=Button(window, text="Abbrechen ",command =stop)
b3.grid(row=4, column = 2, padx= (100,5), pady=5)
window.protocol("WM_DELETE_WINDOW", on_closing)
window.mainloop()