4. The import section

The first line of our python script will be the import section. Here we must include all the python modules we will need for our applet to run:

            import sys
            import pygtk
            import gtk
            import gtk.glade
            import gnome.applet
            import gnome.ui
            import os.path
            import re
            import gobject
            import sample_globals as pglobals

As we can see, we need some GTK and GNOME modules, the gobject module (only if we subclass the applet from it) and the sample_globals, that is used in order to have a easy installation with autotools. The file sample_globals.py is maked when executing the configure script, and it contains the following in my gnome installation:

            name = "sample"
            version = "0.2"
            image_dir = "/usr/share/pixmaps" 
            glade_dir = "/usr/share/" + name
We can use this information to call to gnome.init() or glade.XML() methods and the ones that use images or icons as parameters, such as the about_box or the applet itself WITHOUT using absolute paths.