LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to assign an icon to a window icon in the Ubuntu launcher? (https://www.linuxquestions.org/questions/linux-software-2/how-to-assign-an-icon-to-a-window-icon-in-the-ubuntu-launcher-4175679682/)

Pedroski 07-30-2020 10:37 PM

How to assign an icon to a window icon in the Ubuntu launcher?
 
I made a couple of tkinter windows in Python. They both work and do what I want.

I assigned 2 launchers to them with a file like this in /home/pedro/.local/share/applications

Quote:

[Desktop Entry]
Type=Application
Terminal=false
Name=My Tk Application
Exec=/home/pedro/myPython/tkinter/master2.py
Icon=/home/pedro/icons/icon1.png
StartupWMClass=myTkApp
and I locked the launchers to side panel in Ubuntu.

When I click one of my launchers, the window opens and I see a grey square with a question mark in it in the launcher panel. I suppose that is the default when no icon is assigned to the window.

Where can I assign a different icon to my window?

Do I need to do that in Python, or where??

ondoho 07-31-2020 07:37 AM

I am unfamiliar with the Ubuntu launcher panel, but:
  • does /home/pedro/icons/icon1.png exist?
  • have you tried using an xdg icon name or have you tried moving icon1.png to /usr/share/pixmaps, or into the /usr/share/icons/hicolor/subfolder theme? In that case you could just call it with "Icon=icon1"

Pedroski 07-31-2020 03:45 PM

The launcher panel is a panel you can place left or right or bottom, I think. I set to "autohide", so it pops up when the mouse goes to the left side of the screen. My one contains a launcher for Firefox, Libre Office, other things.

My icons for my personalized launchers show up fine in the launcher panel.

But when I click the icon, the window opens and another icon appears in the launcher. That icon is the grey square with a question mark. It must be some kind of "default icon" for a window which has no icon assigned to it.

I found a solution in tkinter.

My master window is called master. I made a little icon with the text PyWin, it shows up nicely:

Quote:

master.iconphoto(True, tk.PhotoImage(file='/home/pedro/icons/winicon1.png'))
"True" passes the icon to other windows which open from the master window when I click a button. The master window already has its own icon.

Quote:

# the main window
master = tk.Tk(className='myTkApp')
master.iconphoto(True, tk.PhotoImage(file='/home/pedro/icons/winicon1.png'))
master.title("Master window to run other windows")
master.config(bg='light green')
master.geometry('1340x740')
master['padx'] = 10
master['pady'] = 10


All times are GMT -5. The time now is 09:15 AM.