I have been learning Tkinter, so I took some of my Python programs and made them work in a window.
By chance, I saw this way of launching a Python program on Stack Overflow, so I tried it.
Then I made an icon and put this code in /home/pedro/.local/share/applications/
[Desktop Entry]
Type=Application
Terminal=false
Name=Mark CW and HW
Exec=/home/pedro/myPython/tkinter/answersToExcel2.py
Icon=/home/pedro/icons/icon4.png
StartupWMClass=myTkApp
I have never done anything like this before, but to my surprise, it works fine! I locked the icon to my launcher. Now I can start my Tkinter window anytime from the launcher.
My question is: Where can I get more information about what should, must or can be in this kind of [Desktop Entry]
?
Also, if for some reason the python code fails (not happened yet, I test thoroughly in Idle first) will an error message be written somewhere?
A
.desktop
launcher follows freedesktop.org desktop entry and menu standards. Some standard keys are:Name=
Specific name of the application.Comment=
A short description of the application.Exec=
Command to launch the application.Icon=
Icon for the application (an icon provided by your icon theme or an absolute path to an image file).Type=
Types of desktop entries, supported ones areApplication
,Link
orDirectory
.Terminal=
true
/false
, whether the application runs in a terminal window.Categories=
Categories to which the application belongs (Main Categories, Additional Categories and Reserved Categories).StartupWMClass=
is a very useful one.For a detailed list of specifications, visit freedesktop.org.
P.S. Various GUI applications which can be used to create application launchers, e.g. 'Main Menu' (aka
alacarte
) or 'MenuLibre' (menulibre
), just creates a.desktop
file in an appropriate location (e.g.~/.local/share/applications/
) under the hood.The other part of your question:
Programs that are designed for the CLI (and some GUI ones too) usually write all their informational and error messages to stdout and stderr which are normally connected to a terminal/CLI. When you start such programs from a GUI, these streams are usually connected to bit buckets (/dev/null) and all such messages are lost.
When a GUI program misbehaves, a handy trick is to run it from within a terminal. Then, any such messages it issues will have a place to go and may tell you why things aren't working as desired.
A number of GUI programs are quite loquacious when run this way.
In KDE (and probably elsewhere), the Application Menu Editor allows you to select an option for an entry to run in a terminal. This causes a terminal window to automatically open when you run such an entry. When the program is done, the terminal window closes, so if you need to see the final messages, you have to add something that pauses the program or a wrapper script at the end so you can read the messages before they disappear.