Jun-24-2018, 11:19 AM
Hello I am a c# coder and I am learning Python so be kind please.
I just can't figure out why this code isn't working.
My intensions are to let a screen appear and when I push a button a thread gets started.
When I push another button a variable gets changed so that a led starts blinking on my raspberry pi.
I just can't figure out why this code isn't working.
My intensions are to let a screen appear and when I push a button a thread gets started.
When I push another button a variable gets changed so that a led starts blinking on my raspberry pi.
import tkinter as tk from time import sleep import threading from gpiozero import LED blink=False led=LED(14) screen = tk.Tk() screen.title("Control panel") #screen.attributes('-fullscreen', True) def click(): global blink if blink==True: blink=False else: blink=True yaw = tk.Button(screen,text="Click for blink loop",command=click()) yaw.pack() screen.mainloop() def printer(): global blink while 1: led.on() sleep(2) led.off() sleep(2) th = threading.Thread(printer()) threads.append(th) th.start()