Bonjour à tous, voilà une amie et moi devons faire un programme scientifique. Mais nous avons un énorme problème malgré de nombreuses recherches. On veut créer un jeu sur les 20 acides aminées en mettant plusieurs images de ces acides et en insérant juste à côté un choix multiple ( un genre de check liste) qui en cliquant dessus nous montrera si la réponse correspond à la photo ( système de vérification).
Nous avons fait ce code en tkinter sur python 3 ( ci dessous) qui je vous l'accorde est déjà trop long mais surtout les images ne s'appliquent pas , le programme montre juste des cases de couleur.. Pouvez vous, nous aider à raccourcir ce code et surtout nous permettre de mettre plusieurs images? Merci
from tkinter import *
fen1 = Tk()
# création d'un widget 'Canvas' contenant une image bitmap :
can1 = Canvas(fen1, width =160, height =160, bg ='white')
photo = PhotoImage(file ='ala.gif')
item = can1.create_image(80, 80, image =photo)
can2 = Canvas(fen1, width =160, height =160, bg ='black')
photo = PhotoImage(file ='leu.gif')
item = can2.create_image(100, 100, image =photo)
can3 = Canvas(fen1, width =160, height =160, bg ='blue')
photo = PhotoImage(file ='gly.gif')
item = can3.create_image(200, 200, image =photo)
can4 = Canvas(fen1, width =160, height =160, bg ='green')
photo = PhotoImage(file ='gly.gif')
item = can4.create_image(200, 200, image =photo)
can5 = Canvas(fen1, width =160, height =160, bg ='gold')
photo = PhotoImage(file ='gly.gif')
item = can5.create_image(200, 200, image =photo)
can6 = Canvas(fen1, width =160, height =160, bg ='magenta')
photo = PhotoImage(file ='gly.gif')
item = can6.create_image(200, 200, image =photo)
can7 = Canvas(fen1, width =160, height =160, bg ='#234567')
photo = PhotoImage(file ='gly.gif')
item = can7.create_image(200, 200, image =photo)
can8 = Canvas(fen1, width =160, height =160, bg ='#098765')
photo = PhotoImage(file ='gly.gif')
item = can8.create_image(200, 200, image =photo)
can9 = Canvas(fen1, width =160, height =160, bg ='#453627')
photo = PhotoImage(file ='gly.gif')
item = can9.create_image(200, 200, image =photo)
can10 = Canvas(fen1, width =160, height =160, bg ='#102938')
photo = PhotoImage(file ='gly.gif')
item = can10.create_image(200, 200, image =photo)
can11 = Canvas(fen1, width =160, height =160, bg ='#928374')
photo = PhotoImage(file ='gly.gif')
item = can11.create_image(200, 200, image =photo)
can12 = Canvas(fen1, width =160, height =160, bg ='#610384')
photo = PhotoImage(file ='gly.gif')
item = can12.create_image(200, 200, image =photo)
can13 = Canvas(fen1, width =160, height =160, bg ='#777777')
photo = PhotoImage(file ='gly.gif')
item = can13.create_image(200, 200, image =photo)
can14 = Canvas(fen1, width =160, height =160, bg ='#001234')
photo = PhotoImage(file ='gly.gif')
item = can14.create_image(200, 200, image =photo)
can15 = Canvas(fen1, width =160, height =160, bg ='#619247')
photo = PhotoImage(file ='gly.gif')
item = can15.create_image(200, 200, image =photo)
can16 = Canvas(fen1, width =160, height =160, bg ='#716354')
photo = PhotoImage(file ='gly.gif')
item = can16.create_image(200, 200, image =photo)
can17 = Canvas(fen1, width =160, height =160, bg ='#840294')
photo = PhotoImage(file ='gly.gif')
item = can17.create_image(200, 200, image =photo)
can18 = Canvas(fen1, width =160, height =160, bg ='#386334')
photo = PhotoImage(file ='gly.gif')
item = can18.create_image(200, 200, image =photo)
can19 = Canvas(fen1, width =160, height =160, bg ='#046384')
photo = PhotoImage(file ='gly.gif')
item = can19.create_image(200, 200, image =photo)
can20 = Canvas(fen1, width =160, height =160, bg ='#105384')
photo = PhotoImage(file ='gly.gif')
item = can20.create_image(200, 200, image =photo)
# Mise en page à l'aide de la méthode 'grid' :
can1.grid(row =1, column =1, rowspan =3, padx =[0,100], pady =5)
can2.grid(row =10, column =1, rowspan =3, padx =[0,100], pady =5)
can3.grid(row =20, column =1, rowspan =3, padx =[0,100], pady =5)
can4.grid(row =30, column =1, rowspan =3, padx =[0,100], pady =5)
can5.grid(row =40, column =1, rowspan =3, padx =[0,100], pady =5)
can6.grid(row =1, column =2, rowspan =3, padx =[100,200], pady =5)
can7.grid(row =10, column =2, rowspan =3, padx =[100,200], pady =5)
can8.grid(row =20, column =2, rowspan =3, padx =[100,200], pady =5)
can9.grid(row =30, column =2, rowspan =3, padx =[100,200], pady =5)
can10.grid(row =40, column =2, rowspan =3, padx =[100,200], pady =5)
can11.grid(row =1, column =3, rowspan =3, padx =[0,200], pady =5)
can12.grid(row =10, column =3, rowspan =3, padx =[0,200], pady =5)
can13.grid(row =20, column =3, rowspan =3, padx =[0,200], pady =5)
can14.grid(row =30, column =3, rowspan =3, padx =[0,200], pady =5)
can15.grid(row =40, column =3, rowspan =3, padx =[0,200], pady =5)
can16.grid(row =1, column =4, rowspan =3, padx =[0,200], pady =5)
can17.grid(row =10, column =4, rowspan =3, padx =[0,200], pady =5)
can18.grid(row =20, column =4, rowspan =3, padx =[0,200], pady =5)
can19.grid(row =30, column =4, rowspan =3, padx =[0,200], pady =5)
can20.grid(row =40, column =4, rowspan =3, padx =[0,200], pady =5)
# démarrage :
fen1.mainloop()