load all icons found in path, subdirs '<package>/icons/<appname>'.
    Package is optional.

def load_icons(appname, package=""):
    """
    load all icons found in path, subdirs '<package>/icons/<appname>'.
    Package is optional.
    """
    # loop over system path
    global __icons_loaded
    if __icons_loaded:
        return
    icon_paths = ['/usr/local/share/meqtrees'] + sys.path
    for path in icon_paths:
        path = path or '.'
        # for each entry, try <entry>/icons/<appname>'
        trydir = os.path.join(path, package, 'icons', appname)
        _dprint(3, 'trying icon path', trydir)
        try:
            files = os.listdir(trydir)
        except:
            continue
        _dprint(3, len(files), 'entries in', trydir)
        # loop over all files
        nicons = 0
        for f in files:
            (name, ext) = os.path.splitext(f);  # check extension
            if ext in ('.png', '.xpm', '.gif'):
                f = os.path.join(trydir, f)
                try:
                    pm = QPixmap(f)
                except:
                    _dprint(3, 'error loading icon', name, sys.exc_value())
                    continue
                # register pixmap as global symbol using the supplied name
                if name in globals():
                    globals()[name].assign(pm)
                else:
                    globals()[name] = QPixmapWrapper(pm)
                nicons += 1
                _dprint(4, 'loaded icon', f)
            else:
                _dprint(4, 'ignoring entry', f)
        _dprint(1, nicons, 'icons loaded from ', trydir)
        __icons_loaded = True