#----------------------------------------------------------------------# Name: PaletteMapping.py# Purpose: Module that initialises the Palette's data and provides# the namespace in which design time code is evaluated## Author: Riaan Booysen## Created: 1999# RCS-ID: $Id$# Copyright: (c) 1999 - 2004 Riaan Booysen# Licence: GPL#----------------------------------------------------------------------""" Based on core support preferences this module initialises Companion, Model,View and Controller classes. It also executes all active Plug-ins.The namespace of this module is used to evalute code at Design-Time with evalCtrl.Hence the needed import * and execfile."""# XXX This module should be renamed it's function has changed over time# XXX Maybe: BoaNamespace/DesignTimeNamespaceimportosimportPreferences,Utils,PluginsfromPreferencesimportISimportPaletteStorefromwxPython.wximport*ifPreferences.csWxPythonSupport:# This should be the first time the Companion classes are imported# As the modules are imported they add themselves to the PaletteStorefromCompanions.Companionsimport*fromCompanions.FrameCompanionsimport*fromCompanions.WizardCompanionsimport*fromCompanions.ContainerCompanionsimport*ifPreferences.dsUseSizers:fromCompanions.SizerCompanionsimport*fromCompanions.BasicCompanionsimport*fromCompanions.ButtonCompanionsimport*fromCompanions.ListCompanionsimport*fromCompanions.GizmoCompanionsimport*fromCompanions.LibCompanionsimport*ifUtils.IsComEnabled():fromCompanions.ComCompanionsimport*# Define and add a User page to the palettePaletteStore.paletteLists['User']=upl=[]PaletteStore.palette.append(['User','Editor/Tabs/User',upl])fromCompanions.UtilCompanionsimport*fromCompanions.DialogCompanionsimport*# Zope requires spesific supportifPlugins.transportInstalled('ZopeLib.ZopeExplorer'):fromZopeLib.ZopeCompanionsimport*#-Controller imports which auto-registers themselves on the Palette-------------fromModelsimportEditorHelperifPreferences.csPythonSupport:importModels.PythonControllersifPreferences.csWxPythonSupport:importModels.wxPythonControllersifPreferences.csPythonSupportandnotPreferences.csWxPythonSupport:# useful hack to alias wxApp modules to PyApp modules when wxPython support# is not loadedfromModels.PythonEditorModelsimportPyAppModelEditorHelper.modelReg['App']=PyAppModel# The text and makepy controllers are registered outside the Controllers# module so that their palette order can be fine tunedfromModelsimportControllersPaletteStore.newControllers['Text']=Controllers.TextControllerPaletteStore.paletteLists['New'].append('Text')#-Registration of other built in support----------------------------------------ifPreferences.csConfigSupport:fromModelsimportConfigSupportifPreferences.csCppSupport:fromModelsimportCPPSupportifPreferences.csHtmlSupport:fromModelsimportHTMLSupportifPreferences.csXmlSupport:fromModelsimportXMLSupportifPlugins.transportInstalled('ZopeLib.ZopeExplorer'):importZopeLib.ZopeEditorModelsifUtils.IsComEnabled():PaletteStore.newControllers['MakePy-Dialog']=Controllers.MakePyControllerPaletteStore.paletteLists['New'].append('MakePy-Dialog')#-Plug-ins initialisation-------------------------------------------------------ifPreferences.pluginPaths:print'executing plug-ins...'fails=Preferences.failedPluginssucceeded=Preferences.installedPluginsforpluginFilename,ordered,enabledinPlugins.buildPluginExecList():ifnotenabled:continuepluginBasename=os.path.basename(pluginFilename)filename=pluginFilename.lower()try:execfile(pluginFilename)succeeded.append(filename)exceptPlugins.SkipPluginSilently,msg:fails[filename]=('Skipped',msg)exceptPlugins.SkipPlugin,msg:fails[filename]=('Skipped',msg)wxLogWarning('Plugin skipped: %s, %s'%(pluginBasename,msg))exceptException,error:fails[filename]=('Error',str(error))ifPreferences.pluginErrorHandling=='raise':raiseelifPreferences.pluginErrorHandling=='report':wxLogError('Problem executing plug-in %s:\n%s'%\
(pluginBasename,str(error)))# else ignore# XXX legacy referencespalette=PaletteStore.palettenewPalette=PaletteStore.newPalettedialogPalette=PaletteStore.dialogPalettezopePalette=PaletteStore.zopePalettehelperClasses=PaletteStore.helperClassescompInfo=PaletteStore.compInfo_NB=NonedefevalCtrl(expr,localsDct=None):""" Function usually used to evaluate source snippets. Uses the namespace of this module which contain all the wxPython libs and also adds param localDct. """global_NBifnot_NB:_NB=IS.load('Images/Inspector/wxNullBitmap.png')ifnotlocalsDct:localsDct={'wxNullBitmap':_NB}else:localsDct['wxNullBitmap']=_NBlocalsDct['_']=strreturneval(expr,globals(),localsDct)