即时通讯新的初学者在python和im试图让用户输入任何时间,并与时间进行比较。当我尝试下面的编码时钟的结果没有显示确切的time.instead它打印不同的价值。很感激,如果你能帮助。如何比较确切的时间与python进入时间
from Tkinter import*
from time import sleep
import time
import serial
root=Tk()
time1 = ''
clock = Label(font=('times', 20, 'bold'), bg='pink',fg='red')
print(clock)
clock.pack(fill=X,expand=1)
label=Label(text="Add New Time")
time_entry = Entry()
label.pack()
time_entry.pack()
def tick():
global time1
time2 = time.strftime('%H: %M')
if time2 != time1:
time1 = time2
clock.config(text=time2)
clock.after(200, tick)
def tick2():
if clock == time_entry.get():
print("Correct")
else:
print("Wrong")
root.destroy()
button = Button(root,text="submit",command=tick2)
button.pack()
tick()
root.mainloop()
the red which i rounded is the value that dont show the exact time
您在这里没有使用PyGTK +。因此,我删除了该标签。 – zondo