M
M
m1kz2020-05-09 15:26:42
Python
m1kz, 2020-05-09 15:26:42

How to make a window with refreshable text in Tkintere Python?

I want to create a timer, it works in cmd, I want the value of the variable to change in the window every second, but I don’t know how to do it.
An example of a simple program:

import time

x=0
for i in range(100):
    x+=1
    time.sleep(1)
    print(x)


It is necessary that 'x' be in the window of some GUI (maybe Tkinter) and change its value every second.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
YariKartoshe4ka, 2020-05-09
@m1kz

It would be nice to learn a simple GUI, maybe Tkinter

from tkinter import Tk, Label
from time import sleep

root = Tk()

label = Label(text='something')
label.pack()

for x in range(100):
    sleep(1)
    label.config(text=str(x))
    root.update()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question