私はターニングホイールのアニメーションを作成しようとしていますが、whileループで少し遅れて、毎回ホイールを更新したいと考えています。私は、tkinterの "after"関数とpythonの "sleep"関数の両方を試しましたが、衝突を起こすか、または終了して、ホイールが回転している間に実際のアニメーションが表示されません。whileループはtkinterアニメーションでは機能しません
私は回し車用に作成された機能:
def turning():
#initial wheel position
global position
pos(position)
#infinite loop turning the wheel
while(1):
root.after(1000, spin)
def spin():
global position
global speed
delspike() #delete current wheel
position += speed #calculate next position
if position > 360:
position -= 360
pos(position) #draw new wheel
は、なぜこれが動作しませんか?
ホイールを描画または再描画した後、 'root.update_idletasks()'を呼び出してみてください。 – martineau
@Pythonista:いいえ、while whileループは解決策ではありません。まったく同じ悪い振る舞いをします。 –