During the GUI creation procedure for the tkinter library, when setting the window icon,
What is wrong with the image loading error when I write down the icon specification twice?
Usually, it is said that you should not specify it twice, but the build fails after passing through.
I don't get an error code, so I don't know why.
i icon.ico is located directly under the directory in the relative path and is referenced directly under the directory in the cd configuration when running at the anaconda prompt.
#Normal Example
import tkinter as tk
root=tk.Tk()
root.title ('Window Name')
root.geometry ('300x200')
root.iconbitmap(default='icon.ico')
root.mainloop()
# a bad example
import tkinter as tk
root=tk.Tk()
root.title ('Window Name')
root.geometry ('300x200')
root.iconbitmap(default='icon.ico')
root.iconbitmap(default='icon.ico')
root.mainloop()
I checked and found that there are several ways to set icons on Tkinter.
Maybe the link below will improve it.
·www.delftstack.com
·Stackoverflow.com
© 2024 OneMinuteCode. All rights reserved.