Problème affichage image
KRO
-
critou -
critou -
Bonjour,
je programme un jeu qui contient des images en png. Lorsque je teste mon programme sur un ordinateur windows les photos s'affiche mais lorsque je teste sur un mac elles ne s'affichent pas, je ne comprend pas pourquoi...
Je vous montre mon code, soyez indulgents je débute :)
Merci d'avance.
je programme un jeu qui contient des images en png. Lorsque je teste mon programme sur un ordinateur windows les photos s'affiche mais lorsque je teste sur un mac elles ne s'affichent pas, je ne comprend pas pourquoi...
Je vous montre mon code, soyez indulgents je débute :)
Merci d'avance.
import tkinter as tk import os from PIL import Image, ImageTk #Création de la fenêtre d'introduction fenetreintro = tk.Tk() label = tk.Label(fenetreintro, text="Wanted") label.pack() canvas=tk.Canvas(fenetreintro, width=800, height=500, background='white') canvas.pack() #Chemin pour les images script_dir = os.path.dirname(__file__) rel_path = "/images/" abs_file_path = script_dir + rel_path photo = Image.open(abs_file_path+"wanted.jpeg") photowanted = ImageTk.PhotoImage(photo) wanted=canvas.create_image(400, 200, image=photowanted) #Fenêtre jeu def faireApparaitreLeToplevel(): canvasjeu.pack() #Fenêtre instructions def ApparitionToplevel(): top2=tk.Toplevel() lab=tk.Label(top2, text="INSTRUCTIONS AU JEU") lab.pack() bouton1=tk.Button(fenetreintro, text="PLAY", command=faireApparaitreLeToplevel) bouton1.pack() bouton2=tk.Button(fenetreintro, text="Instructions", command=ApparitionToplevel) bouton2.pack() bouton3=tk.Button(fenetreintro, text="Quitter", command=fenetreintro.destroy) bouton3.pack() fenetrejeu = tk.Toplevel() label = tk.Label(fenetrejeu, text="Wanted-Jeu") label.pack() canvasjeu=tk.Canvas(fenetrejeu, width=800, height=800, background='white') #Insertion images image = Image.open(abs_file_path+"baptiste.png") photobaptiste = ImageTk.PhotoImage(image) baptiste=canvasjeu.create_image(100, 250, image=photobaptiste) image = Image.open(abs_file_path+"clarys.png") photoclarys = ImageTk.PhotoImage(image) clarys=canvasjeu.create_image(200, 300, image=photoclarys) image = Image.open(abs_file_path+"anais.png") photoanais = ImageTk.PhotoImage(image) anais=canvasjeu.create_image(300, 350, image=photoanais) image = Image.open(abs_file_path+"allan.png") photoallan = ImageTk.PhotoImage(image) allan=canvasjeu.create_image(400, 450, image=photoallan) image = Image.open(abs_file_path+"arnold.png") photoarnold = ImageTk.PhotoImage(image) arnold=canvasjeu.create_image(500, 350, image=photoarnold) image = Image.open(abs_file_path+"thomas.png") photothomas = ImageTk.PhotoImage(image) thomas=canvasjeu.create_image(600, 550, image=photothomas) image = Image.open(abs_file_path+"ayoub.png") photoayoub = ImageTk.PhotoImage(image) ayoub=canvasjeu.create_image(700, 400, image=photoayoub) image = Image.open(abs_file_path+"caroline.png") photocaroline = ImageTk.PhotoImage(image) caroline=canvasjeu.create_image(250, 450, image=photocaroline) image = Image.open(abs_file_path+"deborah.png") photodeborah = ImageTk.PhotoImage(image) deborah=canvasjeu.create_image(350, 600, image=photodeborah) image = Image.open(abs_file_path+"louis.png") photolouis = ImageTk.PhotoImage(image) louis=canvasjeu.create_image(450, 550, image=photolouis) image = Image.open(abs_file_path+"paul.png") photopaul = ImageTk.PhotoImage(image) paul=canvasjeu.create_image(650, 300, image=photopaul) image = Image.open(abs_file_path+"nono.png") photonono = ImageTk.PhotoImage(image) nono=canvasjeu.create_image(550, 500, image=photonono) fenetreintro.mainloop() fenetrejeu.mainloop()
A voir également:
- Problème affichage image
- Image iso - Guide
- Affichage double ecran - Guide
- Problème affichage fenêtre windows 10 - Guide
- Windows 11 affichage classique - Guide
- Acronis true image - Télécharger - Sauvegarde