我正在尝试制作动画,该动画只是一条从左向右移动的线,并且我正在尝试使其成为流畅的动画。但是,当我按Display_icon时,它会一直移动并且不会执行动画。我如何才能使动画从A点流畅地移动到B点?
这里有一些代码:
from tkinter import * # Import the tkinter module (For the Graphical User Interface)
from PIL import ImageTk,Image # PILLOW for image formatting
width = 1920
height = 1080
RootGeo = str(width) + "x" + str(height) # Make a def for RootGeo so the Root geometry isn't hardcoded
Root = Tk()
Settings_icon = Canvas(Root,bg="red",width=110,height=30)
Display_icon = Canvas(Root,height=30)
Line_icon = Canvas(Root,width=225,height=10)
Line = Line_icon.create_line(5,6,110,width=5)
def Display_Click(event):
print("[DISPLAY_CLICK] [INFO] [DEBUG] Display_icon has been clicked.")
for i in range(10)
Line_icon.move(Line,5,0)
Root.after(1000,Display_Click)
def Settings_click(event):
print("[SETTINGS_CLICK] [INFO] [DEBUG] Settings_icon has been clicked.")
def PicDir(PictureName):
__DIRECTORY__ = "C:\\Users\\Gotta\\PythonProjects\\AutoCam\\Icons\\"
__PICTURE_DIRECTORY__ = __DIRECTORY__ + PictureName
print("[PICDIR] [INFO] [DEBUG] Photo Directory: ",__PICTURE_DIRECTORY__)
return __PICTURE_DIRECTORY__
def MakeWindow():
# -----Root_Attributes-----
Root.geometry(RootGeo)
Root.state("zoomed")
Root.configure(bg="blue")
# -----Root_Attributes,Root_Containers-----
Settings_icon.create_text(57,17,text="Settings",font="arial 20 bold")
Settings_icon.bind("<ButtonRelease>",Settings_click)
Settings_icon.place(x=5,y=5)
Display_icon.create_text(57,text="Display",font="arial 20 bold")
Display_icon.bind("<ButtonRelease>",Display_Click)
Display_icon.place(x=120,y=5)
Line_icon.place(x=5,y=40)
'''RUN COMMAND: py -3 tkinkertest.py'''
# -----Root_Containers----- ### NOT WORKING ###
Root.mainloop()
MakeWindow()
我们将不胜感激。