I want to break a loop with the same button I started it. The code below doesn't work because it ends the loop after "sleep(2)".
I know that "camera.capture_continuous" is specific for the PiCamera but maybe someone can still help me to find a solution. ;)
import tkinter as tk
from picamera import PiCamera
root = tk.Tk()
camera = PiCamera()
def start_tl():
if rec_btn.config('text')[-1] == 'START':
rec_btn.config(text='STOP')
for filename in camera.capture_continuous('/tl_img{counter:03d}.jpg', use_video_port=True):
sleep(2)
if rec_btn.config('text')[-1] == 'START':
break
rec_btn = tk.Button(root,text="START", command=start_tl)
rec_btn.pack()
root.mainloop()