jason10
Posts: 4
Joined: Fri Apr 03, 2020 11:51 pm

world time schedule with user input

Sun Apr 05, 2020 12:11 am

Hello, i have come upon another problem where i have no idea how to get the user input to put the time they want for the led to turn on

Code: Select all

def schedule():
    hour_of_day_start = e3.get()
    minute_of_day_start = e4.get()

    hour_of_day_finish = e5.get()
    minute_of_day_finish = e6.get()
    
    print("test one")
        
    while True:
        print("in loop")
        time_start = datetime.datetime.now().strftime("%H:%M")
        print("Testing time_start variable")
        if time_start == "10:03":
            print("test time")
            red_on()
            time.sleep(5)
            red_off
        elif button_cancel == True:
            cancel()
        break    
        time.sleep(0.030)
this is where my problem is, i put the print for debugging and i saw that it will not go past the

Code: Select all

print("Testing time_start variable")
and also how will i be able to get the number from the entry and put it as the time they want it on, like lets say they want to have it on a 9:43, they will put 09 in one box and 43 in the other and the led will turn on. how am i able to do that??

thank you in advance :)

Garvan
Posts: 41
Joined: Sun Jan 05, 2020 9:59 am

Re: world time schedule with user input

Mon Apr 06, 2020 3:01 am

[[Deleted]] See response below for reason code does not work.
Last edited by Garvan on Mon Apr 06, 2020 7:33 am, edited 1 time in total.

User avatar
rpdom
Posts: 17029
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: world time schedule with user input

Mon Apr 06, 2020 5:51 am

If you mean that your function doesn't sit and wait for the correct time, is that because the "break" should be indented to the same level as cancel() ? Otherwise it will always break out of the while loop the first time it run it.
Unreadable squiggle

Return to “Python”