Partage
  • Partager sur Facebook
  • Partager sur Twitter

client gui

je compte faire un client Minecraft mais je rencontre un problème

Sujet résolu
3 janvier 2022 à 21:33:56

Bonjour/soir je rencontre un problème face à mon client qui actuellement n'en ai qu'à la GUI je n'arrive pas à le résoudre

<pre class="brush: python;">import tkinter as tk

from tkinter import *
from PIL import ImageTk, Image
import PIL.Image

bynight = tk.Tk()
bynight.title('Bynight private client')
bynight.minsize(800, 500)
bynight.maxsize(800, 500)

fond = PhotoImage(file="fond.png")

canvas = Canvas(bynight,width=800, height=500)
canvas.create_image(0, 0, anchor=NW, image=fond)
canvas.pack()


bynight.mainloop()</pre>.  et cela m'affiche cela

Traceback (most recent call last):

  File "C:\Users\bar-m\Desktop\DEV\bynight\main.py", line 11, in <module>

    fond = PhotoImage(file="fond.png")

  File "C:\Users\bar-m\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 4064, in __init__

    Image.__init__(self, 'photo', name, cnf, master, **kw)

  File "C:\Users\bar-m\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 4009, in __init__

    self.tk.call(('image', 'create', imgtype, name,) + options)

_tkinter.TclError: couldn't open "fond.png": no such file or directory

  • Partager sur Facebook
  • Partager sur Twitter
4 janvier 2022 à 14:18:26

il faut être sûr du chemin de fond.png par rapport à ton fichier python et au chemin de travail; là il dit qu'il ne le trouve pas.
  • Partager sur Facebook
  • Partager sur Twitter
5 janvier 2022 à 21:50:12

Il faut écouter ton interpréteur python : il ne trouve pas l'image. Vérifie qu'elle est au bon endroit, essaie aussi
fond = PhotoImage(file="\fond.png")
  • Partager sur Facebook
  • Partager sur Twitter