3

I have a question.

How is it possible to change the icon on the title bar, on a tkinter window?

I've tried .iconbitmap(). but it doesn't seem to work.

nbro
  • 15,395
  • 32
  • 113
  • 196
Vamoos
  • 327
  • 4
  • 10

2 Answers2

5

https://stackoverflow.com/a/18538416/4577427

that answer works fine, I tested it with a .exe and it took the icon of the .exe (didn't have a .ico handy) tkinter_using_factorio_ico

from tkinter import *
root = Tk()

root.iconbitmap(r'C:\Program Files\Factorio\bin\x64\Factorio.exe')
root.mainloop()

it needs the whole path, not just a part

Community
  • 1
  • 1
Venya
  • 190
  • 7
  • how did u do it without putting full location path . if the ico in current directory –  Dec 02 '20 at 09:40
  • 1
    @GHOSTH4CK3R I needed the whole path for the file. Also I prefixed the string with an "r" to make Python ignore special characters (eg \\). – Venya Dec 02 '20 at 10:03
  • 1
    @GHOSTH4CK3R you can't just use the name instead of the full path, unless the icon is in the main directory of the project. If the python file is in any sub directory and the icon is also in that, still you will need either the full path, or the relative path (relative to the main folder) to that icon. – DaniyalAhmadSE Jun 05 '21 at 13:26
0

You Can Use An '.ico' File To Change The Title Icon.

Heres The Code

root.iconbitmap(r'E:\\Projects\\Applications\\Nex Calculator\\icon.ico')

The Result: The Icon Popped Up!

Mista
  • 1