How do I change the icon of a simple dialog in tkinter, Python

1.6k views Asked by At

Not sure how to change the icon of a simple dialog window. I try to use .bitmap but doesn't work. Need Help

2

There are 2 answers

1
Arib Muhtasim On BEST ANSWER

Just add the default keyword argument to the iconbitmap() for the icon of the root, then all the child windows will inherit the icon.

import tkinter
from tkinter import simpledialog

root = tkinter.Tk()
root.iconbitmap(default="C:\\Users\\username\\random.ico")

dialog = simpledialog.askstring("INFO", "wut ur name?")

root.mainloop()

Result with default:

Results without default:

0
Utpal Kumar On

Are you looking for this

from tkinter import Tk
master = Tk()

photo = PhotoImage(file = "Any image file")
master.iconphoto(False, photo)