~ubuntu-branches/debian/experimental/spyder/experimental

« back to all changes in this revision

Viewing changes to spyderlib/guiconfig.py

  • Committer: Package Import Robot
  • Author(s): Picca Frédéric-Emmanuel
  • Date: 2013-02-27 09:51:28 UTC
  • mfrom: (1.1.18)
  • Revision ID: package-import@ubuntu.com-20130227095128-wtx1irpvf4vl79lj
Tags: 2.2.0~beta3+dfsg-1
* Imported Upstream version 2.2.0~beta3+dfsg
* debian /patches
  - 0002-feature-forwarded-add-icon-to-desktop-file.patch (deleted)
    this patch was integrated by the upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
from spyderlib.widgets.sourcecode.syntaxhighlighters import (
26
26
                                 COLOR_SCHEME_KEYS, COLOR_SCHEME_NAMES, COLORS)
27
27
 
28
 
IMG_PATH = []
29
 
def add_image_path(path):
30
 
    if not osp.isdir(path):
31
 
        return
32
 
    global IMG_PATH
33
 
    IMG_PATH.append(path)
34
 
    for _root, dirs, _files in os.walk(path):
35
 
        for dir in dirs:
36
 
            IMG_PATH.append(osp.join(path, dir))
37
 
 
38
 
add_image_path(get_module_data_path('spyderlib', relpath='images'))
39
 
 
40
 
from spyderlib.otherplugins import PLUGIN_PATH
41
 
if PLUGIN_PATH is not None:
42
 
    add_image_path(osp.join(PLUGIN_PATH, 'images'))
43
 
 
44
 
def get_image_path(name, default="not_found.png"):
45
 
    """Return image absolute path"""
46
 
    for img_path in IMG_PATH:
47
 
        full_path = osp.join(img_path, name)
48
 
        if osp.isfile(full_path):
49
 
            return osp.abspath(full_path)
50
 
    if default is not None:
51
 
        return osp.abspath(osp.join(img_path, default))
52
 
 
53
 
def get_icon( name, default=None ):
54
 
    """Return image inside a QIcon object"""
55
 
    if default is None:
56
 
        return QIcon(get_image_path(name))
57
 
    elif isinstance(default, QIcon):
58
 
        icon_path = get_image_path(name, default=None)
59
 
        return default if icon_path is None else QIcon(icon_path)
60
 
    else:
61
 
        return QIcon(get_image_path(name, default))
62
 
 
63
 
def get_image_label( name, default="not_found.png" ):
64
 
    """Return image inside a QLabel object"""
65
 
    label = QLabel()
66
 
    label.setPixmap(QPixmap(get_image_path(name, default)))
67
 
    return label
68
28
 
69
29
def font_is_installed(font):
70
30
    """Check if font is installed"""