Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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!!!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
165 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...