【发布时间】:2019-03-23 03:19:58
【问题描述】:
我正在制作一个使用这个等式的程序:
16*(falling_speed)^2 = 高度
这基本上需要您跌倒的时间,并使用它来确定您从多高的位置跌落。
我知道如何使用方程式,但我的问题是,如何将标签调整为 1 秒或 2 秒?
我试图让它们成为单独的标签,但这也没有用。
这是我的代码:
from tkinter import *
from time import *
print("""This is an app that basically you time the amount of time someone takes to fall from a cliff, then we will
use an equation to tell you how high the cliff is.
This is a recreation of the app Mark Rober created, by The way""")
window = Tk()
window.title("falling app")
window.geometry("700x700")
window.configure(bg = "sky blue")
"""We will use time import for this"""
timer = Label(window, text = "0:00", font = ("verdana", 60))
timer.place(relx = 0.4, rely = 0.35, anchor = "nw")
def start():
mins = 0
seconds = 0
while seconds != 60:
sleep(1.00)
seconds+=1
if seconds == 60:
mins = mins+1
seconds = 0
这一行:timer = Label(window, text = "0:00", font = ("verdana", 60))
是什么使文本。有没有办法在创建后更改文本?
提前致谢!!!
【问题讨论】:
-
使用
timer["text"] = "some_text",或timer.config(text="some_text") -
我以为 config 只在 Canvas tkinter 中使用
-
另外,你可以把这个作为答案
-
所有小部件都有
configure方法,您可以找到很好的参考here。 -
但是你不能把这个作为答案
标签: python-3.x tkinter label