【发布时间】:2016-05-10 01:41:44
【问题描述】:
下面,我创建了一个代码来跟踪一个人正在跑步的圈数。目前,我创建的按钮跟踪圈数和时间,但不在 GUI 窗口上。我想知道如何使代码中的数据显示在 GUI 窗口上。
from Tkinter import *
import time
laps=[0]
gui=Tk()
gui.geometry("200x100")
gui.title("lapping")
def afterbutton():
label_1=Label(gui,text=end())
def end():
end = time.time()
elapsed = end - start
laps[0]+=1
print "%s seconds" % (elapsed)
print "%s lap(s)" % (laps)
starting = raw_input("start? (s to start)")
if starting == "s":
start = time.time()
button1=Button(gui,command=afterbutton,text="lap")
button1.grid()
button1.pack()
gui.mainloop()
【问题讨论】:
标签: python user-interface tkinter