searching for plugins in XRCEDPATH
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44814 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -380,16 +380,12 @@ class PullDownMenu:
|
|||||||
ID_NEW.HELP_BUTTON: ('wxID_HELP', '&Help'),
|
ID_NEW.HELP_BUTTON: ('wxID_HELP', '&Help'),
|
||||||
ID_NEW.CONTEXT_HELP_BUTTON: ('wxID_CONTEXT_HELP', '&Help'),
|
ID_NEW.CONTEXT_HELP_BUTTON: ('wxID_CONTEXT_HELP', '&Help'),
|
||||||
}
|
}
|
||||||
self.clearCustom()
|
self.custom = ['custom', 'User-defined controls']
|
||||||
|
|
||||||
def clearCustom(self):
|
|
||||||
# Custom controls
|
|
||||||
self.custom = [['custom', 'User-defined controls']]
|
|
||||||
self.customMap = {}
|
self.customMap = {}
|
||||||
|
|
||||||
def addCustom(self, klass):
|
def addCustom(self, klass):
|
||||||
n = len(self.custom[0])-2
|
n = len(self.custom)-2
|
||||||
self.custom[0].append((ID_NEW.CUSTOM + n, klass))
|
self.custom.append((ID_NEW.CUSTOM + n, klass))
|
||||||
self.customMap[ID_NEW.CUSTOM + n] = klass
|
self.customMap[ID_NEW.CUSTOM + n] = klass
|
||||||
|
|
||||||
|
|
||||||
@@ -429,6 +425,7 @@ class HighLightBox:
|
|||||||
l4 = wx.Window(w, -1, wx.Point(pos.x, pos.y + size.height - 2), wx.Size(size.width, 2))
|
l4 = wx.Window(w, -1, wx.Point(pos.x, pos.y + size.height - 2), wx.Size(size.width, 2))
|
||||||
l4.SetBackgroundColour(wx.RED)
|
l4.SetBackgroundColour(wx.RED)
|
||||||
self.lines = [l1, l2, l3, l4]
|
self.lines = [l1, l2, l3, l4]
|
||||||
|
self.size = size
|
||||||
# Move highlight to a new position
|
# Move highlight to a new position
|
||||||
def Replace(self, pos, size):
|
def Replace(self, pos, size):
|
||||||
if size.width == -1: size.width = 0
|
if size.width == -1: size.width = 0
|
||||||
@@ -437,6 +434,7 @@ class HighLightBox:
|
|||||||
self.lines[1].SetDimensions(pos.x, pos.y, 2, size.height)
|
self.lines[1].SetDimensions(pos.x, pos.y, 2, size.height)
|
||||||
self.lines[2].SetDimensions(pos.x + size.width - 2, pos.y, 2, size.height)
|
self.lines[2].SetDimensions(pos.x + size.width - 2, pos.y, 2, size.height)
|
||||||
self.lines[3].SetDimensions(pos.x, pos.y + size.height - 2, size.width, 2)
|
self.lines[3].SetDimensions(pos.x, pos.y + size.height - 2, size.width, 2)
|
||||||
|
self.size = size
|
||||||
# Remove it
|
# Remove it
|
||||||
def Remove(self):
|
def Remove(self):
|
||||||
map(wx.Window.Destroy, self.lines)
|
map(wx.Window.Destroy, self.lines)
|
||||||
@@ -785,16 +783,22 @@ class XML_Tree(wx.TreeCtrl):
|
|||||||
if not obj or xxx.hasStyle and xxx.params.get('hidden', False):
|
if not obj or xxx.hasStyle and xxx.params.get('hidden', False):
|
||||||
if g.testWin.highLight: g.testWin.highLight.Remove()
|
if g.testWin.highLight: g.testWin.highLight.Remove()
|
||||||
return
|
return
|
||||||
pos = self.FindNodePos(item, obj)
|
pos = self.FindNodePos(item, obj)
|
||||||
size = obj.GetSize()
|
size = obj.GetSize()
|
||||||
# Highlight
|
# Highlight
|
||||||
# Negative positions are not working quite well
|
# Negative positions are not working quite well
|
||||||
if g.testWin.highLight:
|
hl = g.testWin.highLight
|
||||||
g.testWin.highLight.Replace(pos, size)
|
# If highlight object has the same size SetDimension does not repaint it
|
||||||
|
# so we must remove the old HL window
|
||||||
|
if hl and hl.size == size:
|
||||||
|
hl.Remove()
|
||||||
|
hl = None
|
||||||
|
if hl:
|
||||||
|
hl.Replace(pos, size)
|
||||||
else:
|
else:
|
||||||
g.testWin.highLight = HighLightBox(pos, size)
|
g.testWin.highLight = hl = HighLightBox(pos, size)
|
||||||
g.testWin.highLight.Refresh()
|
hl.Refresh()
|
||||||
g.testWin.highLight.item = item
|
hl.item = item
|
||||||
|
|
||||||
def ShowTestWindow(self, item):
|
def ShowTestWindow(self, item):
|
||||||
xxx = self.GetPyData(item)
|
xxx = self.GetPyData(item)
|
||||||
@@ -1130,8 +1134,8 @@ class XML_Tree(wx.TreeCtrl):
|
|||||||
if xxx.__class__ is not xxxFrame:
|
if xxx.__class__ is not xxxFrame:
|
||||||
m.Enable(ID_NEW.MENU_BAR, False)
|
m.Enable(ID_NEW.MENU_BAR, False)
|
||||||
# Add custom controls menu
|
# Add custom controls menu
|
||||||
if pullDownMenu.customMap:
|
if len(pullDownMenu.custom) > 2:
|
||||||
SetMenu(m, pullDownMenu.custom)
|
SetMenu(m, [pullDownMenu.custom])
|
||||||
m.AppendSeparator()
|
m.AppendSeparator()
|
||||||
m.Append(ID_NEW.REF, 'reference...', 'Create object_ref node')
|
m.Append(ID_NEW.REF, 'reference...', 'Create object_ref node')
|
||||||
m.Append(ID_NEW.COMMENT, 'comment', 'Create comment node')
|
m.Append(ID_NEW.COMMENT, 'comment', 'Create comment node')
|
||||||
|
@@ -339,12 +339,6 @@ class Frame(wx.Frame):
|
|||||||
self.SetAutoLayout(True)
|
self.SetAutoLayout(True)
|
||||||
self.SetSizer(sizer)
|
self.SetSizer(sizer)
|
||||||
|
|
||||||
# Save sys.modules names
|
|
||||||
self.modules = set(sys.modules.keys())
|
|
||||||
|
|
||||||
# Initialize
|
|
||||||
self.Clear()
|
|
||||||
|
|
||||||
# Other events
|
# Other events
|
||||||
wx.EVT_IDLE(self, self.OnIdle)
|
wx.EVT_IDLE(self, self.OnIdle)
|
||||||
wx.EVT_CLOSE(self, self.OnCloseWindow)
|
wx.EVT_CLOSE(self, self.OnCloseWindow)
|
||||||
@@ -1358,13 +1352,11 @@ Homepage: http://xrced.sourceforge.net\
|
|||||||
conf.panelWidth, conf.panelHeight = self.miniFrame.GetSize()
|
conf.panelWidth, conf.panelHeight = self.miniFrame.GetSize()
|
||||||
evt.Skip()
|
evt.Skip()
|
||||||
|
|
||||||
|
|
||||||
def CreateLocalConf(self, path):
|
def CreateLocalConf(self, path):
|
||||||
name = os.path.splitext(path)[0]
|
name = os.path.splitext(path)[0]
|
||||||
name += '.xcfg'
|
name += '.xcfg'
|
||||||
return wx.FileConfig(localFilename=name)
|
return wx.FileConfig(localFilename=name)
|
||||||
|
|
||||||
|
|
||||||
def Clear(self):
|
def Clear(self):
|
||||||
self.dataFile = ''
|
self.dataFile = ''
|
||||||
conf.localconf = None
|
conf.localconf = None
|
||||||
@@ -1381,10 +1373,10 @@ Homepage: http://xrced.sourceforge.net\
|
|||||||
xxxMenuBar, xxxMenu, xxxToolBar,
|
xxxMenuBar, xxxMenu, xxxToolBar,
|
||||||
xxxWizard, xxxBitmap, xxxIcon]:
|
xxxWizard, xxxBitmap, xxxIcon]:
|
||||||
self.maxIDs[cl] = 0
|
self.maxIDs[cl] = 0
|
||||||
# Handlers
|
# Restore handlers, menu, etc. to initial
|
||||||
clearHandlers()
|
setHandlers(self.handlers[:])
|
||||||
g.pullDownMenu.clearCustom()
|
g.pullDownMenu.custom = self.custom[:]
|
||||||
# Delete modules imported from comment directives
|
# Remove modules imported from comment directives
|
||||||
map(sys.modules.pop, [m for m in sys.modules if m not in self.modules])
|
map(sys.modules.pop, [m for m in sys.modules if m not in self.modules])
|
||||||
|
|
||||||
def SetModified(self, state=True):
|
def SetModified(self, state=True):
|
||||||
@@ -1636,6 +1628,31 @@ Please upgrade wxWidgets to %d.%d.%d or higher.''' % MinWxVersion)
|
|||||||
# Create main frame
|
# Create main frame
|
||||||
frame = Frame(pos, size)
|
frame = Frame(pos, size)
|
||||||
frame.Show(True)
|
frame.Show(True)
|
||||||
|
|
||||||
|
# Load plugins
|
||||||
|
plugins = os.getenv('XRCEDPATH')
|
||||||
|
if plugins:
|
||||||
|
cwd = os.getcwd()
|
||||||
|
try:
|
||||||
|
for dir in plugins.split(':'):
|
||||||
|
if os.path.isdir(dir):
|
||||||
|
# Normalize
|
||||||
|
dir = os.path.abspath(os.path.normpath(dir))
|
||||||
|
sys.path = sys_path + [os.path.dirname(dir)]
|
||||||
|
try:
|
||||||
|
os.chdir(dir)
|
||||||
|
__import__(os.path.basename(dir), globals(), locals(), ['*'])
|
||||||
|
except:
|
||||||
|
print traceback.print_exc()
|
||||||
|
finally:
|
||||||
|
os.chdir(cwd)
|
||||||
|
# Store important data
|
||||||
|
frame.handlers = getHandlers()[:]
|
||||||
|
frame.custom = g.pullDownMenu.custom[:]
|
||||||
|
frame.modules = set(sys.modules.keys())
|
||||||
|
|
||||||
|
# Initialize
|
||||||
|
frame.Clear()
|
||||||
|
|
||||||
# Load file after showing
|
# Load file after showing
|
||||||
if args:
|
if args:
|
||||||
|
@@ -920,6 +920,11 @@ class xxxUnknown(xxxObject):
|
|||||||
# Comment
|
# Comment
|
||||||
|
|
||||||
_handlers = [] # custom handler classes/funcs
|
_handlers = [] # custom handler classes/funcs
|
||||||
|
def getHandlers():
|
||||||
|
return _handlers
|
||||||
|
def setHandlers(handlers):
|
||||||
|
global _handlers
|
||||||
|
_handlers = handlers
|
||||||
_CFuncPtr = None # ctypes function type
|
_CFuncPtr = None # ctypes function type
|
||||||
|
|
||||||
def register(hndlr):
|
def register(hndlr):
|
||||||
@@ -935,13 +940,18 @@ def register(hndlr):
|
|||||||
_handlers.append(hndlr)
|
_handlers.append(hndlr)
|
||||||
|
|
||||||
def load_dl(path, localname=''):
|
def load_dl(path, localname=''):
|
||||||
"""Load shared/dynamic library into xxx namespace."""
|
"""Load shared/dynamic library into xxx namespace.
|
||||||
|
|
||||||
|
If path is not absolute or relative, try to find in the module's directory.
|
||||||
|
"""
|
||||||
if not localname:
|
if not localname:
|
||||||
localname = os.path.basename(os.path.splitext(path)[0])
|
localname = os.path.basename(os.path.splitext(path)[0])
|
||||||
try:
|
try:
|
||||||
import ctypes
|
import ctypes
|
||||||
global _CFuncPtr
|
global _CFuncPtr
|
||||||
_CFuncPtr = ctypes._CFuncPtr
|
_CFuncPtr = ctypes._CFuncPtr # use as a flag of loaded ctypes
|
||||||
|
#if not os.path.dirname(path) and os.path.isfile(path):
|
||||||
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
wx.LogError('ctypes module not found')
|
wx.LogError('ctypes module not found')
|
||||||
globals()[localname] = None
|
globals()[localname] = None
|
||||||
@@ -974,10 +984,6 @@ def addHandlers():
|
|||||||
wx.LogError('error adding XmlHandler: "%s"' % h)
|
wx.LogError('error adding XmlHandler: "%s"' % h)
|
||||||
print traceback.print_exc()
|
print traceback.print_exc()
|
||||||
|
|
||||||
def clearHandlers():
|
|
||||||
global _handlers
|
|
||||||
_handlers = []
|
|
||||||
|
|
||||||
def custom(klassName, klass='unknown'):
|
def custom(klassName, klass='unknown'):
|
||||||
"""Define custom control based on xrcClass.
|
"""Define custom control based on xrcClass.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user