Tkinter定时while循环不会接受int

时间:2019-12-10 12:32:10

标签: python tkinter int

我制作了一个python Tkinter GUI,它从用户处获取一个时间值,并放入一个while循环,该循环在用户定义的时间结束后结束。即使我尝试将用户输入值转换为int,我仍然遇到错误。

# time labels
label17 = Label(second_frame, text='Time Interval (Secs)', bg='white')
label17.grid(row=2, padx=0, pady=5)
label18 = Label(second_frame, text='Total Test Time (Days)', bg='white')
label18.grid(row=3, padx=0, pady=5)
# time entries
entry_ti = Entry(second_frame, bg="white")
entry_ti.grid(row=2, column=2, padx=10, pady=5)
entry_tt = Entry(second_frame, bg="white")
entry_tt.grid(row=3, column=2, padx=10, pady=5)

test_time = int(entry_tt.get())
interval_time = int(entry_ti.get())

def start_testing():
    try:
        while int(time.time()) <= int(test_time):
            logger.debug('Test has started ')
            temp ='outputting test result'
            output.insert(0, temp)
            logger.debug('outputting test result ')

    except Exception as e:  # general exceptions
        logger.error('Something went wrong: ' + str(e))
    else: # goes here if no exception was thrown
        logger.debug('everything was successfully executed')

    finally:  # always goes here after finishing from the script
        logger.debug('test has ended')

我得到的错误是:

Something went wrong: '<' not supported between instances of 'float' and 'str'```

0 个答案:

没有答案