When creating the Python Tkinter GUI, icon files cannot be read correctly after setting the icon image twice.

Asked 2 years ago, Updated 2 years ago, 330 views

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()

Enter a description of the image here

python tkinter

2022-10-24 00:00

1 Answers

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


2022-10-24 00:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.