嗨,你可以帮我解决这个问题吗(对不起,我对英语不是很擅长) 我希望在tkinter显示tkinter之后添加图片(照片1)。 我需要在5秒后出现照片1,知道这只是一个"孔代码的一个模块" 这是我的代码:
from tkinter import *
import random
import time
import instructions_traits
x = float()
x = 0.0
aClique =0
Mafenetre = None
varcc = 0
def add():
global x
global Mafenetre
x+=0.001
Mafenetre.after(1,add)
def apparaitre(Canevas):
global photo1
photo1 = PhotoImage(file="homer simpson.gif")
item1 = Canevas.create_image(300,200,anchor=NW, image=photo1)
add()
def Clic(event):
global aClique
global x
global varcc
global Mafenetre
if aClique == 0:
aClique = 1
print (x)
if x <=0.350 and x >=0.2:
varb=0
if x >=0.351:
varb=5
Mafenetre.destroy()
instructions_traits.play(varcc, varb)
def play(varc):
# Creation de la fenetre principale (main window)
global Mafenetre
global varcc
varcc = varc
Mafenetre = Tk()
Mafenetre.title('jeu')
Mafenetre.configure(width=1550,height=700)
# Image de fond
photo = PhotoImage(file="fond homer.gif")
# Creation d'un widgetCanvas (zone graphique)
Largeur = 1550
Hauteur = 700
Canevas = Canvas(Mafenetre,width = Largeur, height =Hauteur)
Canevas.bind('<Button-1>', Clic)
item = Canevas.create_image(0,0,anchor=NW, image=photo)
Canevas.pack(side = LEFT, padx = 10, pady = 10)
"""Mafenetre.after(5000,apparaitre(Canevas))"""
time.sleep( 25 )
apparaitre(Canevas)
Mafenetre.mainloop()