本文整理汇总了Python中component.Manager.preload方法的典型用法代码示例。如果您正苦于以下问题:Python Manager.preload方法的具体用法?Python Manager.preload怎么用?Python Manager.preload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类component.Manager
的用法示例。
在下文中一共展示了Manager.preload方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createTestWin
# 需要导入模块: from component import Manager [as 别名]
# 或者: from component.Manager import preload [as 别名]
def createTestWin(self, item):
TRACE('createTestWin')
# Create a window with this resource
node = view.tree.GetPyData(item)
# Close old window, remember where it was
comp = Manager.getNodeComp(node)
# Create memory XML file
elem = node.cloneNode(True)
if not node.hasAttribute('name'):
name = 'noname'
else:
name = node.getAttribute('name')
elem.setAttribute('name', STD_NAME)
Model.setTestElem(elem)
Model.saveTestMemoryFile()
xmlFlags = 0
if not g.conf.useSubclassing:
xmlFlags |= xrc.XRC_NO_SUBCLASSING
# Use translations if encoding is not specified
if not Model.dom.encoding:
xmlFlags |= xrc.XRC_USE_LOCALE
res = xrc.EmptyXmlResource(xmlFlags)
xrc.XmlResource.Set(res) # set as global
# Init other handlers
Manager.addXmlHandlers(res)
Manager.preload(res)
# Same module list
res.Load('memory:test.xrc')
object = None
testWin = view.testWin
try:
try:
frame, object = comp.makeTestWin(res, name)
if not object: # skip the rest
raise EOFError
# Reset previous tree item and locate tool
if testWin.item:
view.tree.SetItemBold(testWin.item, False)
testWin.SetView(frame, object, item)
testWin.Show()
view.tree.SetItemBold(item, True)
except EOFError:
pass
except NotImplementedError:
wx.LogError('Test window not implemented for %s' % node.getAttribute('class'))
logger.exception('error creating test view')
except:
logger.exception('error creating test view')
wx.LogError('Error creating test view')
if get_debug(): raise
finally:
# Cleanup
res.Unload(TEST_FILE)
xrc.XmlResource.Set(None)
wx.MemoryFSHandler.RemoveFile(TEST_FILE)
示例2: createTestWin
# 需要导入模块: from component import Manager [as 别名]
# 或者: from component.Manager import preload [as 别名]
def createTestWin(self, item):
TRACE('createTestWin')
# Create a window with this resource
node = view.tree.GetPyData(item)
# Execute "pragma" comment node
if node.nodeType == node.COMMENT_NODE:
if node.data and node.data[0] == '%' and g.conf.allowExec != 'no':
say = wx.NO
if g.conf.allowExec == 'ask' and Model.allowExec is None:
say = wx.MessageBox('Execute comment directive?', 'Warning',
wx.ICON_EXCLAMATION | wx.YES_NO)
if g.conf.allowExec == 'yes' or say == wx.YES:
code = node.data[1:] # skip '%'
view.tree.ExecCode(code)
return
# Close old window, remember where it was
comp = Manager.getNodeComp(node)
# Create memory XML file
elem = node.cloneNode(True)
if not node.hasAttribute('name'):
name = 'noname'
else:
name = node.getAttribute('name')
elem.setAttribute('name', STD_NAME)
Model.setTestElem(elem)
Model.saveTestMemoryFile()
xmlFlags = 0
if not g.conf.useSubclassing:
xmlFlags |= xrc.XRC_NO_SUBCLASSING
# Use translations if encoding is not specified
if not Model.dom.encoding:
xmlFlags |= xrc.XRC_USE_LOCALE
res = xrc.EmptyXmlResource(xmlFlags)
xrc.XmlResource.Set(res) # set as global
# Init other handlers
Manager.addXmlHandlers(res)
Manager.preload(res)
# Same module list
res.Load('memory:test.xrc')
object = None
testWin = view.testWin
try:
try:
frame, object = comp.makeTestWin(res, name)
if not object: # skip the rest
raise EOFError
# Reset previous tree item and locate tool
if testWin.item:
view.tree.SetItemBold(testWin.item, False)
testWin.SetView(frame, object, item)
testWin.Show()
view.tree.SetItemBold(item, True)
except EOFError:
pass
except NotImplementedError:
wx.LogError('Test window not implemented for %s' % node.getAttribute('class'))
logger.exception('error creating test view')
except:
logger.exception('error creating test view')
wx.LogError('Error creating test view')
if get_debug(): raise
finally:
# Cleanup
res.Unload(TEST_FILE)
xrc.XmlResource.Set(None)
wx.MemoryFSHandler.RemoveFile(TEST_FILE)
示例3: createTestWin
# 需要导入模块: from component import Manager [as 别名]
# 或者: from component.Manager import preload [as 别名]
def createTestWin(self, item):
TRACE("createTestWin")
# Create a window with this resource
node = view.tree.GetPyData(item)
# Execute "pragma" comment node
if node.nodeType == node.COMMENT_NODE:
if node.data and node.data[0] == "%" and g.conf.allowExec != "no":
say = wx.NO
if g.conf.allowExec == "ask" and Model.allowExec is None:
say = wx.MessageBox("Execute comment directive?", "Warning", wx.ICON_EXCLAMATION | wx.YES_NO)
if g.conf.allowExec == "yes" or say == wx.YES:
code = node.data[1:] # skip '%'
view.tree.ExecCode(code)
return
# Close old window, remember where it was
comp = Manager.getNodeComp(node)
# Use parent object if the current one does not support test view
testWinItem = item
while not comp.isTestable:
testWinItem = view.tree.GetItemParent(testWinItem)
node = view.tree.GetPyData(testWinItem)
comp = Manager.getNodeComp(node)
# Create memory XML file
elem = node.cloneNode(True)
if not node.hasAttribute("name"):
name = "noname"
else:
name = node.getAttribute("name")
elem.setAttribute("name", STD_NAME)
Model.setTestElem(elem)
Model.saveTestMemoryFile()
xmlFlags = 0
if not g.conf.useSubclassing:
xmlFlags |= xrc.XRC_NO_SUBCLASSING
# Use translations if encoding is not specified
if not Model.dom.encoding:
xmlFlags |= xrc.XRC_USE_LOCALE
res = xrc.EmptyXmlResource(xmlFlags)
xrc.XmlResource.Set(res) # set as global
# Init other handlers
Manager.addXmlHandlers(res)
Manager.preload(res)
# Same module list
res.Load("memory:test.xrc")
testWin = view.testWin
try:
try:
frame, object = comp.makeTestWin(res, name)
if not object: # skip the rest
raise EOFError
# Reset previous tree item and locate tool
if testWin.item:
view.tree.SetItemBold(testWin.item, False)
testWin.SetView(frame, object, testWinItem)
testWin.Show()
view.tree.SetItemBold(testWinItem, True)
# For reused frame, object is not positioned immediately
wx.CallAfter(self.highlight, item)
except EOFError:
pass
except TestWinError:
wx.LogError("Test window could not be created for %s" % node.getAttribute("class"))
logger.exception("error creating test view")
except:
wx.LogError("Error creating test view")
logger.exception("error creating test view")
if get_debug():
raise
finally:
# Cleanup
res.Unload(TEST_FILE)
xrc.XmlResource.Set(None)
wx.MemoryFSHandler.RemoveFile(TEST_FILE)