1

I've written a Python script using Tkinter to show one (single) window (the script works fine). Now, I've written a .desktop file to be able to start the script from the Ubuntu (16.04) dash:

[Desktop Entry]
Name=UNIX Time Converter
Exec=/home/tiuri/.local/share/applications/UnixTimeConverter.py
Type=Application
Terminal=False
Icon=/home/tiuri/.local/share/applications/unixtimeconverter.png

But this works only partly: I have an application in the dash with the correct icon and the correct name. On clicking it, two icons appear in the launcher: The application icon (as given in the .desktop) blinks for ten seconds and then disappears, while the second icon is connected to the Tkinter window and stays as long as the window is open. I would, however, like to have only one launcher icon with the image defined in the .desktop file and connected to the Tkinter window.

A minimal example for the Python script to reproduce the behaviour is:

#!/usr/bin/env python

from Tkinter import Tk, Label

def main():
    master = Tk()
    Label(master, text='Minimal example').pack()
    master.mainloop()

if __name__ == '__main__':
   main()

I guess that Ubuntu doesn't recognise the Tkinter window as an instance of the command just executed, but I don't really know whether this is a Python or an Ubuntu problem. Searching here and on Google didn't yield a solution, but maybe you have an idea? Thanks in advance!

2
  • add sheband in first line of script #!/usr/bin/env python and set chmod +x script.py and you can run script as normal program $ script.py - without python. You can event remove extension` Commented Dec 15, 2016 at 17:19
  • Sure, I can do that (I edited the question accordingly). Unfortunately, that doesn't solve the issue with the two launcher icons. Commented Dec 16, 2016 at 9:48

1 Answer 1

1

You can add the StartupWMClass property in the .desktop file , which will identify it as from the application
Run the following command and click on the application, it will output the window class

xprop | grep WM_CLASS | awk '{print $4}'

and put it like

StartupWMClass=<output of above command>

in your .desktop file

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.