本文整理汇总了Python中PyUtils.sameObject方法的典型用法代码示例。如果您正苦于以下问题:Python PyUtils.sameObject方法的具体用法?Python PyUtils.sameObject怎么用?Python PyUtils.sameObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyUtils
的用法示例。
在下文中一共展示了PyUtils.sameObject方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
# 需要导入模块: import PyUtils [as 别名]
# 或者: from PyUtils import sameObject [as 别名]
def update(self, data = None):
"""Called whenever the curve list is updated. Make sure the curve editor list match the application curve list."""
count = self._appCurveList.getCount()
for i in range(count):
inCurve = self._appCurveList.get(i)
inTrajectory1d = inCurve.getTrajectory1d()
try:
outTrajectory1d = self.getTrajectory(i)
areSameObject = PyUtils.sameObject(inTrajectory1d, outTrajectory1d)
except IndexError:
outTrajectory1d = None
areSameObject = False
if not areSameObject:
# Need to delete or insert
# First, check how many curves we should delete
delete = 1
try:
while not PyUtils.sameObject( inTrajectory1d, self.getTrajectory(i+delete) ) :
delete += 1
except IndexError:
delete = 0
if delete > 0 :
# Delete the specified controllers
self._removeCurveEditors(i,i+delete)
else :
# Insert the specified controller
self._insertCurveEditor(i, inCurve)
# Delete any remaining controllers
self._removeCurveEditors(count)
self.getParent().layout()
示例2: update
# 需要导入模块: import PyUtils [as 别名]
# 或者: from PyUtils import sameObject [as 别名]
def update(self, data = None):
"""Called whenever the tree is updated."""
try:
tree = self._infoTree
rootItem = tree.GetRootItem()
nodeData = tree.GetItemPyData( rootItem )
snapshot = nodeData.getObject().getCurrentSnapshot()
except AttributeError: return
if self._activeTreeItemId != None :
currentSnapshot = tree.GetItemPyData( self._activeTreeItemId )
if PyUtils.sameObject(currentSnapshot, snapshot) : return
tree.SetItemBold( self._activeTreeItemId, False )
# Look for the new item
activeList = [tree.GetFirstChild(rootItem)[0]]
while len(activeList) > 0 :
treeItemId = activeList.pop()
if not treeItemId.IsOk(): continue
object = tree.GetItemPyData( treeItemId ).getObject()
if PyUtils.sameObject(snapshot, object) :
self._activeTreeItemId = treeItemId
tree.SetItemBold( treeItemId, True )
return
activeList.append( tree.GetFirstChild(treeItemId)[0] )
activeList.append( tree.GetNextSibling(treeItemId) )
示例3: update
# 需要导入模块: import PyUtils [as 别名]
# 或者: from PyUtils import sameObject [as 别名]
def update(self, object):
"""Adjusts the node's _subTreeItemIds list so that it matches an input object list.
TreeItemId s will be deleted or inserted into _subTreeItemIds based on its current content and
that of the input object list."""
count = self._member.getCount(object)
for i in range(count):
inObject = self._member.getObject(object,i)
try:
outObject = self.getObject(i)
areSameObject = PyUtils.sameObject(inObject, outObject)
except IndexError:
outObject = None
areSameObject = False
if not areSameObject:
# Need to delete or insert
# First, check how many objects we should delete
delete = 1
try:
while not PyUtils.sameObject( inObject, self.getObject(i+delete) ) :
delete += 1
except IndexError:
delete = 0
if delete > 0 :
# Delete the specified objects
self.removeChildren(i,i+delete)
else :
# Insert the specified object
self.insertChild(i, inObject)
# Delete any remaining objects
self.removeChildren(count)
示例4: saveCharacterState
# 需要导入模块: import PyUtils [as 别名]
# 或者: from PyUtils import sameObject [as 别名]
def saveCharacterState(self, event = None):
"""Saves the selected character state"""
controller = self._getSelectedController()
if controller is None : return
app = wx.GetApp()
character = controller.getCharacter()
saveNumber = self._saveNumber
if PyUtils.sameObject( self._lastSave[0], controller ) :
if self._lastSave[1] is not None :
saveNumber = self._lastSave[1]
controllerName = controller.getName()
dialogTitle = "Save Character State for %s" % controllerName
fileName = "%sState_%d.rs" % (controllerName, saveNumber)
dialog = wx.FileDialog(self, dialogTitle, self._dirName, fileName, "*.rs", wx.SAVE | wx.OVERWRITE_PROMPT )
dialog.CenterOnScreen()
if dialog.ShowModal() == wx.ID_OK:
if saveNumber != self._saveNumber:
self._lastSave = (None, None, None)
else:
self._lastSave = (controller, None, self._saveNumber)
self._saveNumber += 1
fileName=dialog.GetFilename()
self._dirName=dialog.GetDirectory()
pathName = os.path.join(self._dirName,fileName)
stateArray = Core.ReducedCharacterStateArray()
if controller.getStance() == Core.RIGHT_STANCE:
character.getReverseStanceState(stateArray)
else:
character.getState(stateArray)
character.saveReducedStateToFile( str(pathName), stateArray )
dialog.Destroy()
示例5: saveController
# 需要导入模块: import PyUtils [as 别名]
# 或者: from PyUtils import sameObject [as 别名]
def saveController(self, event = None):
"""Save the currently selected controller"""
controller = self._getSelectedController()
if controller is None : return
saveNumber = self._saveNumber
if PyUtils.sameObject( self._lastSave[0], controller ) :
if self._lastSave[2] is not None :
saveNumber = self._lastSave[2]
controllerName = controller.getName()
dialogTitle = "Save %s Controller" % controllerName
fileName = "%s_%d.py" % (controllerName, saveNumber)
dialog = wx.FileDialog(self, dialogTitle, self._dirName, fileName, "*.py", wx.SAVE | wx.OVERWRITE_PROMPT )
dialog.CenterOnScreen()
if dialog.ShowModal() == wx.ID_OK:
if saveNumber != self._saveNumber:
self._lastSave = (None, None, None)
else:
self._lastSave = (controller, self._saveNumber, None)
self._saveNumber += 1
fileName=dialog.GetFilename()
self._dirName=dialog.GetDirectory()
pathName = os.path.join(self._dirName,fileName)
file = open(pathName,'w')
file.write( "from App.Proxys import *\n\ndata = %s" % PyUtils.fancify( PyUtils.serialize(controller)) )
file.close()
dialog.Destroy()