如何在tkinter中调整标签?

时间:2019-03-23 03:19:59

标签: python-3.x tkinter label

我正在编写一个使用此方程式的程序:

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)) 是什么使文字。创建文字后,是否可以更改文字?

提前谢谢!

1 个答案:

答案 0 :(得分:0)

您可以使用timer["text"] = "some_text"timer.config(text="some_text")

所有小部件都具有configure方法,您可以找到很好的参考文献here