-
Notifications
You must be signed in to change notification settings - Fork 8
/
PaletteStore.py
53 lines (42 loc) · 1.45 KB
/
PaletteStore.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
42
43
44
45
46
47
48
49
50
51
52
53
from Preferences import IS
from Utils import _
paletteLists = {'New': [],
'Dialogs': [],
'Zope': [],
}
newPalette = [_('New'), 'Editor/Tabs/New', paletteLists['New']]
palette = []
dialogPalette = [_('Dialogs'), 'Editor/Tabs/Dialogs', paletteLists['Dialogs']]
zopePalette = [_('Zope'), 'Editor/Tabs/Zope', paletteLists['Zope']]
helperClasses = {}
compInfo = {}
newControllers = {}
artProviderArtIds = []
#-------------------------------------------------------------------------------
def loadBitmap(name):
""" Loads bitmap if it exists, else loads default bitmap """
imgPath = 'Images/Palette/' + name+'.png'
try:
return IS.load(imgPath)
except IS.Error:
return IS.load('Images/Palette/Component.png')
def bitmapForComponent(wxClass, wxBase='None'):
""" Returns a bitmap for given component class.
"Aquires" bitmap by traversing inheritance thru if necessary.
"""
if wxBase != 'None': return loadBitmap(wxBase)
else:
cls = wxClass
try: bse = wxClass.__bases__[0]
except:
if compInfo.has_key(wxClass):
return loadBitmap(compInfo[wxClass][0])
else:
return loadBitmap('Component')
try:
while not compInfo.has_key(cls):
cls = bse
bse = cls.__bases__[0]
return loadBitmap(compInfo[cls][0])
except:
return loadBitmap('Component')