I'm working on a python script with tkinter. Goal how the program should work: 1: enter an ID & click on "Save ID" (-> Folder with name = ID is created) 2: click on "start capturing" (starting a loop in which u can take as many pictures as u want) 3: make pictures using a physical button 4: after finishing making pictures press "capturing finished" (-> pictures will get send to the folder called ID)
After 4 is finished you can start again by entering a new ID.
Here's the code I'm using:
from tkinter import *
import tkinter.font
import sys, os
from gpiozero import LED
from gpiozero import Button as Knopf
import RPi.GPIO as GPIO
from time import sleep
import datetime
running = True
# Pin Setup ############################################
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
beleuchtung = LED(19)
startsignal = LED(20)
status_led = LED(11)
aufnahme = Knopf(21)
GPIO.setup(8, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(21, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)#capture button
# Funktionen ############################################
# Übertragung der Bilder beginnen # =============
def sendData():
global running
running = False
patId = e1.get()
print(patId)
status_led.blink(on_time=0.25, off_time=0.25, n=None, background=True)
print("starting...")
print("Sending...")
os.system("scp pi@192.168.2.131:/home/pi/Pictures/* /home/pi/Pictures/ID_"+patId+"/")
print("finished")
status_led.off()
# Create Folder with ID # =====================
def setId():
patId = e1.get()
os.system("mkdir /home/pi/Pictures/ID_"+patId)
global running
running = True
return patId
# Aufnahme Funktion (main function) # ===========
def capture():
if running:
status_led.on()
aufnahme.wait_for_press()
status_led.off()
sleep(0.1)
beleuchtung.on() #LED on
sleep(0.1)
startsignal.on() #Sends capture command to camera
sleep(2)
startsignal.off()
beleuchtung.off()
sleep(0.2)
status_led.off()
win.after(1000, capture)
status_led.blink(on_time=1, off_time=1, n=None, background=True)
# Window Setup #########################################
win = Tk()
win.title("cureVision")
win.geometry=("480x320")
myFont = tkinter.font.Font(family ='Helvetica', size = 12, weight = 'bold')
### WIGDETS ###
label = Label(win, text="Patienten ID eingeben...")
label.grid(row=1)
e1 = Entry(win)
e1.grid(row =1, column=1)
Button(win, text='ID bestätigen', command = setId).grid(row=1, column = 2, sticky=W, pady=4)
sendButton = Button(win, text = 'capturing finished' , font = myFont, command = sendData, bg = 'bisque2', height = 2, width = 23)
sendButton.grid(row=3, column=2)
startButton = Button(win, text = 'start capturing' , font = myFont, command = capture, bg = 'bisque2', height = 2, width = 23)
startButton.grid(row=3, column=1)
win.mainloop()
I'm at the point where I can capture as many pictures as I want but i can't click on "capturing finished". Everything else is working fine.