如何在tkinter中调整Label?

问题描述 投票:-1回答:1

我正在制作一个使用这个等式的程序:

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))是文本的原因。有没有办法在创建文本后更改文本?

提前致谢!!!

python-3.x tkinter label
1个回答
0
投票

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

所有小部件都有配置方法,你可以找到很好的参考here

© www.soinside.com 2019 - 2024. All rights reserved.