Setting an application icon

The icing on the cake: of course you want your application to be represented by its very own icon. However, this is not very simple. You first need to get a friendly artist to create a nice icon for you, and set the icon of the toplevel widget to it:

class DocviewApp(QMainWindow):
    """
    DocviewApp combines DocviewDoc and DocviewView
    into a single window, single document application.
    """
    def __init__(self, *args):
        apply(QMainWindow.__init__,(self, ) + args)
        self.setIcon(QPixmap(appicon))
    

This is the icon that will be shown in the titlebar and on the taskbar. The application icon that will be used for shortcuts on the desktop is a different story altogether.

There is absolutely no standard way of setting the icon that is used for a shortcut on the Unix desktop. If you target Gnome, KDE or any of the other Unix desktop environments, you will have to delve into .desktop files and other things. Still, it is possible to create a working .desktop file, for instance for KDE:

[Desktop Entry]
Exec=python main.py
Icon=appicon
Type=Application
DocPath=framework/index.html
MapNotify=true

Name=SDI framework
Name[nl]=SDI raamwerk
    

This one is for the KDE desktop, and exactly where this should go is a deployment issue. The same file should, theoretically, also be usable for Gnome.

On the other hand, setting a default icon for Windows applications is quite impossible, since Windows expects the icon to be part of the application binary.