精灵线条与tkinter线条测试程序对比

精灵线条与tkinter线条测试程序对比

"""以下程序实现线条的移动"""
from tkinter import *
from time import sleep

root = Tk()

w = Canvas(root,width=200, height=200, background="white")
w.pack()

line = w.create_line(50, 100, 100, 100, fill='blue')

for x in range(100):
    w.move(line,1,1)
    w.update()
    sleep(0.01)
"""以下程序也是实现线条的移动"""
from sprites import *

line = Turtle(shape='line')   # 最新版的精灵模块增加了line形状

for x in range(100):
    line.move(1,1)
    time.sleep(0.01)
李兴球

李兴球的博客是Python创意编程原创博客

评论已关闭。