I have my GUI App developed in Python 2.7 . Application will take start time, end time and time interval from user.I have code which will take this input and create a array of time as per the interval. I am trying to implement here a function which will get called at the time which is stored in array and can also be stopped if user press stop button.
time_slots = [dt.strftime('%H:%M:%S') for dt in
datetime_range(start_time,
end_time,timedelta(minutes=interval))]
time_slots_array = np.array(time_slots)
def function1():
print("In function 1")
def start():
global start_time,end_time,time_slots
now_time = datetime.now().time()
t.sleep(1)
keys = sorted(time_slots_arrary
if now_time >= start_time.time() and now_time <= end_time.time():
if now.strftime("%H:%M:%S") in keys:
function1()
job1 = root.after(1000, start())
else:
root.after_cancel(job1)
start_button = tk.Button(prod_frame, text='Start Program ', width=25, background='green', foreground='black',command = start)
stop_button = tk.Button(prod_frame, text='Stop Program ', width=25, background='orange', foreground='black',command = stop)`