13 January, 2016

How to make an icon for a Python App

The files and the icon.


So now I have some Python GUIs for my Philips HUE, but I'd like to have a nice Desktop Icon, like any other Linux App. How can I do this?

In Ubuntu - and probably most Linux systems the paths to executable programs are stored in hidden .desktop files.

First create a file and save it as .myApp.desktop

The content of the file could look like this:


[Desktop Entry]
Name=Test
Exec=/home/per/Dokumenter/bin/bin/hue/python/tkinterNoter/tkEntry.py
Icon=/home/per/Dokumenter/bin/bin/hue/python/tkinterNoter/multimusen.png
Terminal=false
Type=Application
GenericName="Python tkEntry Exp"

There are more possible setting, see here.

The next step is to make your file executable, write these commands in the terminal window:

# chmod a+x .myApp.desktop
# chmod a+x tkEntry.py
# cp .*desktop ~/.local/share/applications/

In order to give all system user access to your program, you can:

# cp .*desktop /usr/share/applications

Now you'll see an icon with the chosen picture in the folder. You can drag this icon to e.g. the menu. And now you can run your GUI as you would run any program.

The line Terminal can be true or false. If it's true the program will launch in a terminal window.

No comments: