-
Notifications
You must be signed in to change notification settings - Fork 9
/
Icons.py
42 lines (32 loc) · 1.09 KB
/
Icons.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from qt import *
import os.path
ICONS_DIR = os.path.join(os.path.dirname(__file__), 'Icons')
def load(iconName):
"""Try to load an icon from file and return the QPixmap object"""
filename = os.path.join(ICONS_DIR, iconName)
if not os.path.exists(filename):
for ext in ['png', 'xpm', 'gif', 'bmp']:
f = '.'.join([filename, ext])
if os.path.exists(f):
filename = f
break
try:
icon = QPixmap(filename)
except:
return QPixmap(os.path.join(ICONS_DIR, 'esrf_logo.png'))
else:
if icon.isNull():
return QPixmap(os.path.join(ICONS_DIR, 'esrf_logo.png'))
else:
return icon
def getIconPath(iconName):
"""Return path to an icon"""
filename = os.path.join(ICONS_DIR, iconName)
if not os.path.exists(filename):
for ext in ['png', 'xpm', 'gif', 'bmp']:
f = '.'.join([filename, ext])
if os.path.exists(f):
filename = f
break
if os.path.exists(filename):
return filename