When I try running the program below, it shows me this error :
Program:
import tkinter as tk
class RootWindow() :
def __init__(self) :
root=tk.Tk()
self.root=root
root.title("Isekai no yusha")
root.wm_iconbitmap(bitmap = "Icon.xbm")
root.configure(bg="black")
root.resizable(width=False, height=False)
screenWidth, screenHeight=root.winfo_screenwidth(), root.winfo_screenheight()
screenWidth, screenHeight=int(screenWidth/2)-400, int(screenHeight/2)-200
self.screenWidth, self.screenHeight=screenWidth, screenHeight
#RootWindow.StartMenu(self)
rootSize=(f"800x400+{screenWidth}+{screenHeight}")
root.geometry(rootSize)
root.mainloop()
#def StartMenu(self) :
# newGameButton=tk.Button(self.root, bitmap=("new_game_icon.xbm"), bg="black", fg="white", border=False, command=self.root.destroy)
# newGameButton.pack()
# newGameButton.place(x=10, y=10)
master=RootWindow()
Error:
Exception has occurred: _tkinter.TclError
bitmap "new_game_icon.xbm" not defined
File "D:\programmation\IDLE RPG\Test2.py", line 24, in StartMenu
newGameButton=tk.Button(self.root, bitmap=("new_game_icon.xbm"), bg="black", fg="white", border=False, command=self.root.destroy)
File "D:\programmation\IDLE RPG\Test2.py", line 17, in __init__
RootWindow.StartMenu(self)
File "D:\programmation\IDLE RPG\Test2.py", line 28, in <module>
master=RootWindow()
I already tried changing file format to png, bmp and xbm but all of them didn't work( the file is already in the working folder and I already checked if the name between the file and the name in the code match). Also, when I try running the program without the Button, the icon in the top left corner of the window isn't showing, I get instead the image of a file. (Screenshot below).
Window icon:
IDE used : Visual Code Studio, OS : Windows 10
Sorry for my poor language, I'm a french student.