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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
#-----------------------------------------------------------------------------
# Name: wxNamespace.py
# Purpose:
#
# Author: Riaan Booysen
#
# Created: 2001
# RCS-ID: $Id: wxNamespace.py,v 1.8 2004/08/16 12:46:39 riaan Exp $
# Copyright: (c) 2001 - 2004
# Licence: GPL
#-----------------------------------------------------------------------------
import Preferences; _Prefs = Preferences; del Preferences
from wxPython.wx import *
if _Prefs.ccImportWxPyUtils:
try: from wxPython.utils import *
except ImportError: pass # >=2.5
if _Prefs.ccImportWxPyHtml:
from wxPython.html import *
if _Prefs.ccImportWxPyHtmlHelp:
try: from wxPython.htmlhelp import *
except ImportError: pass # >=2.5
if _Prefs.ccImportWxPyHelp:
try: from wxPython.help import *
except ImportError: pass # >=2.5
if _Prefs.ccImportWxPyCalendar:
from wxPython.calendar import *
if _Prefs.ccImportWxPyGrid:
from wxPython.grid import *
if _Prefs.ccImportWxPyOgl:
from wxPython.ogl import *
if _Prefs.ccImportWxPyStc:
from wxPython.stc import *
if _Prefs.ccImportWxPyGizmos:
from wxPython.gizmos import *
if _Prefs.ccImportWxPyWizard:
from wxPython.wizard import *
import types; _types = types; del types
# remove wxPython *c modules from namespace
_g = globals()
for _k, _v in _g.items():
if type(_v) is _types.ModuleType and _k[-1] == 'c':
del _g[_k]
del _g, _k, _v
filterTypes = []
if _Prefs.ccFilterWxConstants:
filterTypes.append(_types.IntType)
if _Prefs.ccFilterWxFunctions:
filterTypes.extend( [_types.FunctionType, _types.BuiltinFunctionType])
if _Prefs.ccFilterWxClasses:
filterTypes.append(_types.ClassType)
if _Prefs.ccFilterWxInstances:
filterTypes.append(_types.InstanceType)
def _getWxNameSpace():
if _Prefs.ccFilterWxAll:
return []
g = globals()
ns = filterOnPrefs(g, g)
for name in ('filterTypes', 'getWxNameSpace', 'getWxClass',
'getNamesOfType', '_getWxNameSpace', '_nameSpace'):
try: ns.remove(name)
except ValueError: pass
return ns
def filterOnPrefs(g, w):
ns = g.keys()
if _Prefs.ccFilterWxPtrNames:
return filter(lambda n, g=g, w=w: n[-3:] != 'Ptr' and \
(type(g[n]) not in filterTypes or not w.has_key(n)), ns)
else:
return filter(lambda n, g=g, w=w: \
type(g[n]) not in filterTypes or not w.has_key(n), ns)
def getWxClass(name):
g = globals()
if g.has_key(name) and type(g[name]) == _types.ClassType:
return g[name]
def getNamesOfType(aType):
res = []
for k, v in globals().items():
if type(v) == aType:
if _Prefs.ccFilterWxPtrNames and k[-3:] == 'Ptr':
continue
res.append(k)
return res
def getWxNameSpace():
return _nameSpace
_nameSpace = _getWxNameSpace()
|