Home > other >  Textvariable label, how to just can dynamically display the figures in the loop?
Textvariable label, how to just can dynamically display the figures in the loop?

Time:09-30

Only cycle all run out, such as the code below will show "9999", don't show that intermediate process, consult ace, textvariable label, how to just can dynamically display the figures in the loop? Or use the config (),,
The from tkinter import *
The import time

Root=Tk ()
Root. Geometry (" 250 x150 ")

Val=StringVar ()
L1=Label (root, textvariable=val)
L1. Pack ()
Val=val. Set ("...
")

L2=Label (root, text="PPP")
L2. Pack ()

For a in range (10000) :
I=STR (a)
# val=val. The set (" 8888 ")
L2. Config (text=I)
A +=1
Time. Sleep (0.1)

Root. Mainloop ()

CodePudding user response:

Simple can have a Timer Timer
 
The from tkinter import *
The import time
The from threading import Timer

Root=Tk ()
Root. Geometry (" 250 x150 ")

Val=StringVar ()
L1=Label (root, textvariable=val)
L1. Pack ()
Val=val. Set ("...
")

L2=Label (root, text="PPP")
L2. Pack ()

A=0
Def set_text () :
Global a
L2. Config (text=STR (a))
A +=1
If a & lt; 10000:
T=the Timer (0.1, set_text)
T.s tart ()

T=the Timer (0.1, set_text)
T.s tart ()

# for a in range (10000) :
# I=STR (a)
# # val=val. The set (" 8888 ")
# l2. Config (text=I)
A +=# 1
# time. Sleep (0.1)

Root. Mainloop ()
  • Related