Remplacer un canvas par un autre
Bonjour alors voilà, je veux remplacer un canvas, avec une image dedans, en cliquant sur un bouton : voilà ce que j'ai fais mais la seconde image ( Maths2 ) n'apparait pas...
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
def suivant():
can=Canvas(fen3,height=1000,width=1000,bg="#D58490")
image_2=PhotoImage(file='Maths2.gif')
img=can.create_image(450,450,image=image_2)
can.place(x=0,y=0)
def fen3(): #fenêtre des fiches de Maths
fen3=Toplevel()
fen3.geometry("1000x1000")
fen3.title("Mathématiques, Fiches")
can=Canvas(fen3,height=1000,width=1000,bg="#D58490")
image_1=PhotoImage(file='Maths1.gif')
img=can.create_image(450,450,image=image_1)
can.place(x=0,y=0)
Bout_M=Button(fen3,text="SUIVANT",height=5,width=20,bg="#FCDC12",command=suivant)
Bout_M.place(x=800,y=800)
img.pack() |
Mais Python me dit
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python32\lib\tkinter\__init__.py", line 1399, in __call__
return self.func(*args)
File "U:\Projet Final ISN\Projet.py", line 29, in fen3
img.pack()
AttributeError: 'int' object has no attribute 'pack'
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python32\lib\tkinter\__init__.py", line 1399, in __call__
return self.func(*args)
File "U:\Projet Final ISN\Projet.py", line 14, in suivant
can=Canvas(fen3,height=1000,width=1000,bg="#D58490")
File "C:\Python32\lib\tkinter\__init__.py", line 2098, in __init__
Widget.__init__(self, master, 'canvas', cnf, kw)
File "C:\Python32\lib\tkinter\__init__.py", line 1951, in __init__
BaseWidget._setup(self, master, cnf)
File "C:\Python32\lib\tkinter\__init__.py", line 1929, in _setup
self.tk = master.tk
AttributeError: 'function' object has no attribute 'tk' |