Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to replace the icon in a Tkinter app

I am using Python 3.5.0 on Windows 10 and want to replace this:

with something else.

like image 241
It's Willem Avatar asked Oct 15 '15 00:10

It's Willem


People also ask

How do I change my TK icon?

iconphoto() method in Tkinter | Python iconphoto() method is used to set the titlebar icon of any tkinter/toplevel window. But to set any image as the icon of titlebar, image should be the object of PhotoImage class. Set the titlebar icon for this window based on the named photo images passed through args.

Can tkinter use PNG?

Tkinter relies on Pillow for working with images. Pillow is a fork of the Python Imaging Library, and can be imported in a Python console as PIL. Pillow has the following characteristics: Support for a wide range of image file formats, including PNG, JPEG and GIF.

How do you use Customtkinter?

To use CustomTkinter, just place the /customtkinter folder from this repository next to your program, and then you can do import customtkinter .


2 Answers

To change the icon you should use iconbitmap or wn_iconbitmap I'm under the impression that the file you wish to change it to must be an ico file.

import tkinter as tk

root = tk.Tk()
root.iconbitmap("myIcon.ico")
like image 92
Steven Summers Avatar answered Oct 08 '22 14:10

Steven Summers


input for tkinter

from tkinter import *

app = Tk()
app.title('Tk')
app.geometry('')

app.iconbitmap(r'C:\Users\User\PycharmProjects\HelloWorld\my.ico')
app.mainloop()

input for pyinstaller

pyinstaller --onefile -w -F --add-binary "my.ico;." my.py
like image 35
Shaun Avatar answered Oct 08 '22 16:10

Shaun