|

楼主 |
发表于 2020-3-31 12:41:54
|
显示全部楼层
这里我想让病毒sleep0.05秒
但是我这里飞机也被sleep了 我把他放到一个函数里也不行
你们知道这是怎么回事吗@一个账号
- from tkinter import *
- from tkinter import messagebox
- from PIL import Image, ImageTk
- import time
- root = Tk()
- root.geometry('800x1000+500+0')
- root.title('消灭病毒,中国加油,武汉必胜!')
- def bind_(event):
- if event.keysym == 'Left':
- a.move(img,-10,0)
- if event.keysym == 'Right':
- a.move(img,10,0)
- if event.keysym == 'Up':
- a.move(img,0,-10)
- if event.keysym == 'Down':
- a.move(img,0,10)
- x = 100
- y = 100
- a = Canvas(root, width=800, height=1000)
- a.pack()
- b1 = PhotoImage(file=r'C:\Users\Administrator\Desktop\飞机1.gif')
- img = a.create_image(420, 950, image=b1)
- b2 = PhotoImage(file=r'C:\Users\Administrator\Desktop\病毒1.gif')
- for i in range (1,5):
- img1 = a.create_image(x, y, image=b2)
- img1 = a.create_image(-10, -10, image=b2)
- a.bind_all('<KeyPress-Left>', bind_)
- a.bind_all('<KeyPress-Down>', bind_)
- a.bind_all('<KeyPress-Up>', bind_)
- a.bind_all('<KeyPress-Right>', bind_)
- def aa():
- for x in range(0,10):
- a.move(img1, 0, 50)
- root.update()
- time.sleep(0.05)
- aa()
- root.mainloop()
复制代码 |
|