我对after函数以及它在print(str(type(baseDataList)))
print("baseDataList: ")
for s in baseDataList[:2]:
print(*s
#<class 'list'>
#baseDataList:
#43.646556 -79.470988 5761688733 ...
#43.645314 -79.462791 5761688679 ...
print(str(type(resultData)))
print("resultData: ")
print(str(type(resultData)))
print("Unique: " + str(len(np.unique(resultData>=0)))
#<class 'numpy.ndarray'>
#resultData:
#[ 0 -1 0 5 5 -1 4 10 10 5 10 10 10 10 -1 10 10 10 10 10 4 4 6 1 2
#5 9 -1 10 10 10 6 10 8 10 10 6 8 10 10 3 9 10 10 10 6 6 4 6 6
#10 5 5 4 6 10 6 5 10 5 10 10 10 6 -1 6 4 4 10 10 10 10 10 10 7
#4 10 -1 -1 10 9 -1 5 3 6 6 6 6 6 6 6 4 6 6 4 6 6 6 6 6
#6 6 6 6 6 8 -1 6 10 10 4 4 10 9 -1 9 10 10 5 9 10 4 5 5 10
#6 10 10 5 10 6 5 6 10 10 10 10 10 10 10 10 10 6 4 5 10 -1 9 9 9
#6 10 10 6 1 6 10 10 10 10 10 10 6 5 9 10 10 6 10 10 10 -1 4 3 9
#9 7 5 10 10 10 4 8 -1 -1 6 4 4 6 10 9 6 10 9 10 1 6 10 10 10
#10 -1 6 10 10 9 10 10 2 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
#10 10 10 10 10 -1 1 10 10 1 1 10 10 1 -1 10 1 10 10 10 10 10 10 9 10
#11 11 -1 6 1 6 -1 10 6 4 8 10 10 10 10 8 10 10 10 10 10 11 6 12 12
#10 4 10 10 6 4 -1 4 -1 4 4 4 4 4 4 4 -1 4]
#Unique: 13
print("resultList: ")
print(str(type(resultList)))
for s in resultList[:2]:
print(*s)
#<class 'list'>
#resultList:
#namedResult_tuple(lat=43.646556, lng=79.470988, guid='5761688733', ...)
#namedResult_tuple(lat=43.645314, lng=-79.462791, guid='5761688679', ...)
#...
中的工作原理有疑问。
我已经使下面的代码工作,我注意到我可以多次调用mainloop
函数。这使得球每次被召唤时移动得更快。我想在没有多次按下按钮的情况下重现它。
此外,有人可以解释一下如何按下&#39; go&#39;按钮几次使球变得更快。
PS:对不起我的英语,我是法国人......
after
答案 0 :(得分:0)
from tkinter import *
def speedup():
global vit
if vit>2:
vit-=2
can1.after(500,speedup)
def bouge():
global speedx,speedy,run,i
colors=["white", "black", "red", "green", "blue", "cyan", "yellow"]
pos = can1.coords(oval1)
if pos[0] <= 0 or pos[0] >= 450:
speedx *= -1
can1.itemconfig(oval1,fill=colors[i])
i+=1
i=i%6
if pos[1]<=0 or pos[1]>=450:
speedy*=-1
can1.move(oval1, speedx, speedy)
text1.configure(text=(pos,vit))
if run:
can1.after(vit, bouge)
def stop():
global run
run=False
def start():
global run
run=True
bouge()
speedup()
x1, y1 = 100, 250
speedx=6
speedy=7
run=True
i=0
vit=100
fen1 = Tk()
fen1.title("Arkanoid made by Rico")
can1 = Canvas(fen1, height=500, width=500,background='lightblue')
oval1 = can1.create_oval(x1, y1, x1 + 50, y1 + 50, fill='yellow')
rec1=can1.create_rectangle(225,480,275,500,fill='grey')
pos=can1.coords(oval1)
Button(fen1, text='GO!!', command=start).grid(row=2, column=1, sticky=S)
Button(fen1, text='Quitter', command=fen1.quit).grid(row=2, column=3, sticky=S)
Button(fen1, text='Stop', command=stop).grid(row=2, column=2, sticky=S)
text1=Label(fen1,text=pos)
text1.grid(row=2,column=4)
can1.grid(row=1,columnspan=5)
fen1.mainloop()