如何在Tkinter中调整Label? [英] How to adjust Label in tkinter?

查看:425
本文介绍了如何在Tkinter中调整Label?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am making a program that uses this equation:

16 *(falling_speed)^ 2 =高度

16*(falling_speed)^2 = height

这基本上会花费您跌倒的时间,并用它来确定跌落的高度.

This basically takes the time you are falling and uses it to determine how high you are falling from.

我知道如何使用方程式,但是我的问题是,如何将标签调整为1秒或2秒?

I know how to use the equation, but my question is this, how to adjust the label to 1 second or 2 seconds?

我试图使它们成为单独的标签,但这也不起作用.

I tried to make them seperate labels, but that didn't work either.

这是我的代码:

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

This line: timer = Label(window, text = "0:00", font = ("verdana", 60)) is what makes the text. Is there a way to change text after you have created it?

提前谢谢!

推荐答案

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

所有小部件都具有configure方法,您可以在此处找到.

All widgets have the configure method which you can find good reference here.

这篇关于如何在Tkinter中调整Label?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆