How to adjust Label in tkinter?

被刻印的时光 ゝ 提交于 2019-12-25 18:36:08

问题


I am making a program that uses this equation:

16*(falling_speed)^2 = height

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

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.

Here is my code:

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

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?

Thanks in advance!!!


回答1:


You can use timer["text"] = "some_text", or timer.config(text="some_text").

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



来源:https://stackoverflow.com/questions/55310299/how-to-adjust-label-in-tkinter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!