python3 tkinter on WSL: app icon not being displayed

Viewed 43

I'm using tkinter in Ubuntu (inside Windows Subsystem for Linux (WSL)). I'm trying to set the icon (.icon or .png) to my tkinter app, but all the methods I tried fail. My solutions are based on Set Window Icon in Tkinter.

Here I put my code and the results in comments:

import tkinter as tk

root = tk.Tk()

#root.iconbitmap('./icon.ico')
#error
#return self.tk.call('wm', 'iconbitmap', self._w, bitmap)
#_tkinter.TclError: bitmap "./icon.ico" not defined

#root.tk.call('wm', 'iconphoto', root._w, tk.PhotoImage(file='./logo.png'))
#works, but empty icon

#root.iconphoto(False, tk.PhotoImage(file=r"./logo.png"))
#works, but empty icon

root.mainloop()

This is the empty icon:

enter image description here

All solutions work in Windows.

1 Answers

try removing './' and leave only 'icon.ico'

Related