1
Kaydırıcıyı kullanarak görüntü animasyonu Hızını kontrol etmek istiyorum. Bu yüzden, aşağıdakileri yapmaya çalışıyorum, ancak kaydırıcıyı değiştirdiğimde, aynı tuvalde yeniden görünen birçok görüntü elde ediyorum. Kaydırıcıyı kullanarak bir görüntü ile bir sonraki arasındaki zaman aralığını değiştirmek istiyorum.Python tkinter Sürgü kontrolü
from tkinter import *
#import tkFont
import random
from time import sleep
root = Tk()
class App:
def __init__(self, master):
frame = Frame(master)
frame.pack()
scale = Scale(frame, from_=0, to=100, command=self.update)
scale.grid(row=0)
def update(self, duty):
#Importing the images. They are named a1.gif, a2.gif...a7.gif
frame=[]
for i in range(1,10):
fname="CORE\\a"+str(i)+".gif"
frame+=[PhotoImage(file=fname)]
wrap = Canvas(root, width=200, height=140)
wrap.pack()
def do_animation(currentframe):
def do_image():
wrap.create_image(100,70,image=frame[currentframe], tag='ani')
# Delete the current picture if one exists
wrap.delete('ani')
try:
do_image()
except IndexError:
# End of image list reached, start over at the first image
#- works for an arbitrary number of images
currentframe = 0
do_image()
wrap.update_idletasks() #Force redraw
currentframe = currentframe + 1
# Call myself again to keep the animation running in a loop
root.after(100, do_animation, currentframe)
# Start the animation loop just after the Tkinter loop begins
root.after(100, do_animation, 0)
app = App(root)
#app.geometry("800x480")
root.mainloop()
python
Bu harika, işe yarıyor, Çok teşekkür ederim. Nerede yanlış gittiğimi anlıyorum. –