whenever i make an animation where there is something new being drawn really quickly, when tk opens, the animation is much slower than it should be
however, tk window's speed changes in these circumstances:
- "holding" tk window - it stops and then it continues faster, but not quite as wanted
- on release - it continues with the slow speed (just like when tk first opened)
- moving tk window - the faster you move, the faster the animation gets
- agressive shaking - releasing after shaking, finally leaves it on the necessary speed
you can observe this here:
import random
import time
import tkinter
canvas = tkinter.Canvas(width=1000, height=600, bg='#003359')
canvas.pack()
raindropsF = {}
raindropsB = {}
canvas.create_rectangle(0,510,1000,600,fill='#232323',outline='#232323');
def raining():
rainingF()
rainingB()
def rainingF():
for iF in list(raindropsF):
if raindropsF[iF] < 550:
raindropsF[iF] += 20
canvas.move(iF, 0, 20)
else:
canvas.delete(iF)
del raindropsF[iF]
xF = random.randint(0, 1000)
iF = canvas.create_line(xF, 0, xF, 20, fill='#00CCFF', width=3)
raindropsF[iF] = 0
canvas.after(10, rainingF)
def rainingB():
for iB in list(raindropsB):
if raindropsB[iB] < 520:
raindropsB[iB] += 10
canvas.move(iB, 0, 10)
else:
canvas.delete(iB)
del raindropsB[iB]
xB = random.randint(0, 1000)
iB = canvas.create_line(xB, 0, xB, 20, fill='#0077BB', width=1)
raindropsB[iB] = 0
canvas.after(10, rainingB)
raining()
so is there a way of keeping the performance of tk window consistant
(i don't have a slow pc)