简体   繁体   中英

how to change an app icon in tkinter? I trayed to look online but it didn't work

I'm traying to make an app GUI using tkinter. how do I change the window icon? I trayed to do:

import tkinter as tk
root = tk.Tk()
root.iconbitmap('app_icon.ico')
root.mainloop

I think you have to show that path to the ico picture, try this:

import tkinter as tk
root = tk.Tk()

root.iconbitmap('/path/to/ico/app_icon.ico')
root.mainloop()

Below code worked for me, you can check this for your scenario

from tkinter import *

root=Tk()

p1 = PhotoImage(file = "/path/to/ico/app_icon.ico") 
  
root.iconphoto(False, p1)

root.mainloop()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM