本文整理汇总了Python中direct.gui.DirectGui.DirectScrolledList.removeAndDestroyAllItems方法的典型用法代码示例。如果您正苦于以下问题:Python DirectScrolledList.removeAndDestroyAllItems方法的具体用法?Python DirectScrolledList.removeAndDestroyAllItems怎么用?Python DirectScrolledList.removeAndDestroyAllItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类direct.gui.DirectGui.DirectScrolledList
的用法示例。
在下文中一共展示了DirectScrolledList.removeAndDestroyAllItems方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PartyEditor
# 需要导入模块: from direct.gui.DirectGui import DirectScrolledList [as 别名]
# 或者: from direct.gui.DirectGui.DirectScrolledList import removeAndDestroyAllItems [as 别名]
#.........这里部分代码省略.........
def mouseEnterTrash(self, mouseEvent):
self.mouseOverTrash = True
self.oldInstructionText = self.partyPlanner.instructionLabel['text']
self.partyPlanner.instructionLabel['text'] = TTLocalizer.PartyPlannerEditorInstructionsTrash
def mouseExitTrash(self, mouseEvent):
self.mouseOverTrash = False
self.partyPlanner.instructionLabel['text'] = self.oldInstructionText
def enterHidden(self):
PartyEditor.notify.debug('Enter Hidden')
def exitHidden(self):
PartyEditor.notify.debug('Exit Hidden')
def enterIdle(self, fromDragging = False):
PartyEditor.notify.debug('Enter Idle')
if not fromDragging:
self.elementList.scrollTo(0)
self.elementList['items'][0].elementSelectedFromList()
self.currentElement = self.elementList['items'][self.elementList.getSelectedIndex()]
self.currentElement.checkSoldOutAndPaidStatusAndAffordability()
self.partyPlanner.instructionLabel['text'] = TTLocalizer.PartyPlannerEditorInstructionsIdle
self.updateCostsAndBank()
self.handleMutuallyExclusiveActivities()
def handleMutuallyExclusiveActivities(self):
mutSet = self.getMutuallyExclusiveActivities()
if not mutSet:
return
currentActivities = self.partyEditorGrid.getActivitiesElementsOnGrid()
lastActivity = self.partyEditorGrid.lastActivityIdPlaced
for act in currentActivities:
if act.id in mutSet and not lastActivity == act.id:
act.removeFromGrid()
removedName = TTLocalizer.PartyActivityNameDict[act.id]['editor']
addedName = TTLocalizer.PartyActivityNameDict[lastActivity]['editor']
instr = TTLocalizer.PartyPlannerEditorInstructionsRemoved % {'removed': removedName,
'added': addedName}
self.partyPlanner.instructionLabel['text'] = instr
self.updateCostsAndBank()
def getMutuallyExclusiveActivities(self):
currentActivities = self.partyEditorGrid.getActivitiesOnGrid()
actSet = Set([])
for act in currentActivities:
actSet.add(act[0])
result = None
for mutuallyExclusiveTuples in PartyGlobals.MutuallyExclusiveActivities:
mutSet = Set(mutuallyExclusiveTuples)
inter = mutSet.intersection(actSet)
if len(inter) > 1:
result = inter
break
return result
def updateCostsAndBank(self):
currentActivities = self.partyEditorGrid.getActivitiesOnGrid()
currentDecorations = self.partyEditorGrid.getDecorationsOnGrid()
newCost = 0
for elementTuple in currentActivities:
newCost += PartyGlobals.ActivityInformationDict[elementTuple[0]]['cost']
for elementTuple in currentDecorations:
newCost += PartyGlobals.DecorationInformationDict[elementTuple[0]]['cost']
self.partyPlanner.costLabel['text'] = TTLocalizer.PartyPlannerTotalCost % newCost
if len(currentActivities) > 0 or len(currentDecorations) > 0:
self.partyPlanner.setNextButtonState(enabled=True)
else:
self.partyPlanner.setNextButtonState(enabled=False)
self.partyPlanner.totalCost = newCost
self.partyPlanner.beanBank['text'] = str(int(self.partyPlanner.totalMoney - self.partyPlanner.totalCost))
def exitIdle(self):
PartyEditor.notify.debug('Exit Idle')
def enterDraggingElement(self):
PartyEditor.notify.debug('Enter DraggingElement')
if self.currentElement.isDecoration:
self.partyPlanner.instructionLabel['text'] = TTLocalizer.PartyPlannerEditorInstructionsDraggingDecoration
else:
self.partyPlanner.instructionLabel['text'] = TTLocalizer.PartyPlannerEditorInstructionsDraggingActivity
def exitDraggingElement(self):
PartyEditor.notify.debug('Exit DraggingElement')
def enterCleanup(self):
PartyEditor.notify.debug('Enter Cleanup')
self.partyEditorGrid.destroy()
self.elementList.removeAndDestroyAllItems()
self.elementList.destroy()
self.trashCanButton.unbind(DirectGuiGlobals.ENTER)
self.trashCanButton.unbind(DirectGuiGlobals.EXIT)
self.trashCanButton.destroy()
def exitCleanup(self):
PartyEditor.notify.debug('Exit Cleanup')
示例2: CalendarGuiDay
# 需要导入模块: from direct.gui.DirectGui import DirectScrolledList [as 别名]
# 或者: from direct.gui.DirectGui.DirectScrolledList import removeAndDestroyAllItems [as 别名]
#.........这里部分代码省略.........
self.numberWidget['state'] = DirectGuiGlobals.DISABLED
else:
self.numberWidget.setColorScale(1, 1, 1, 1)
if self.myDate.month != self.startDate.month:
self.setColorScale(0.75, 0.75, 0.75, 1.0)
if self.dayClickCallback is not None:
self.numberWidget['state'] = DirectGuiGlobals.DISABLED
else:
self.setColorScale(1, 1, 1, 1)
if self.myDate.date() == curServerDate.date():
self.defaultBox.hide()
self.todayBox.show()
else:
self.defaultBox.show()
self.todayBox.hide()
return
def destroy(self):
if self.dayClickCallback is not None:
self.numberWidget.destroy()
self.dayClickCallback = None
self.notify.debug('desroying %s' % self.myDate)
try:
for item in self.scrollList['items']:
if hasattr(item, 'description') and item.description and hasattr(item.description, 'destroy'):
self.notify.debug('desroying description of item %s' % item)
item.unbind(DGG.ENTER)
item.unbind(DGG.EXIT)
item.description.destroy()
except e:
self.notify.debug('pass %s' % self.myDate)
self.scrollList.removeAndDestroyAllItems()
self.scrollList.destroy()
self.dayButton.destroy()
DirectFrame.destroy(self)
return
def addWeeklyHolidays(self):
if not self.filter == ToontownGlobals.CalendarFilterShowAll and not self.filter == ToontownGlobals.CalendarFilterShowOnlyHolidays:
return
if base.cr.newsManager:
holidays = base.cr.newsManager.getHolidaysForWeekday(self.myDate.weekday())
holidayName = ''
holidayDesc = ''
for holidayId in holidays:
if holidayId in TTLocalizer.HolidayNamesInCalendar:
holidayName = TTLocalizer.HolidayNamesInCalendar[holidayId][0]
holidayDesc = TTLocalizer.HolidayNamesInCalendar[holidayId][1]
else:
holidayName = TTLocalizer.UnknownHoliday % holidayId
self.addTitleAndDescToScrollList(holidayName, holidayDesc)
self.scrollList.refresh()
if base.config.GetBool('calendar-test-items', 0):
if self.myDate.date() + datetime.timedelta(days=-1) == base.cr.toontownTimeManager.getCurServerDateTime().date():
testItems = ('1:00 AM Party', '2:00 AM CEO', '11:15 AM Party', '5:30 PM CJ', '11:00 PM Party', 'Really Really Long String')
for text in testItems:
newItem = DirectLabel(relief=None, text=text, text_scale=self.ScrollListTextSize, text_align=TextNode.ALeft)
self.scrollList.addItem(newItem)
if self.myDate.date() + datetime.timedelta(days=-2) == base.cr.toontownTimeManager.getCurServerDateTime().date():
testItems = ('1:00 AM Party', '3:00 AM CFO', '11:00 AM Party')
textSize = self.ScrollListTextSize
for text in testItems:
示例3: FriendsList
# 需要导入模块: from direct.gui.DirectGui import DirectScrolledList [as 别名]
# 或者: from direct.gui.DirectGui.DirectScrolledList import removeAndDestroyAllItems [as 别名]
#.........这里部分代码省略.........
self.fsm.enterInitialState()
self.accept('gotFriendsList', self.handleFriendsList)
return
def destroy(self):
self.ignore('gotFriendsList')
self.fsm.requestFinalState()
del self.fsm
self.headingText.destroy()
del self.headingText
self.frameForNames.destroy()
del self.frameForNames
self.fwdBtn.destroy()
del self.fwdBtn
self.backBtn.destroy()
del self.backBtn
self.closeBtn.destroy()
del self.closeBtn
del self.friends
del self.onlineFriends
DirectFrame.destroy(self)
def doState(self, state):
self.fsm.request(state)
def exitClicked(self):
self.fsm.request('off')
base.localAvatar.showFriendButton()
def setButtons(self, fwd = None, back = None):
if fwd:
self.fwdBtn['extraArgs'] = [fwd]
self.fwdBtn['state'] = DGG.NORMAL
else:
self.fwdBtn['extraArgs'] = []
self.fwdBtn['state'] = DGG.DISABLED
if back:
self.backBtn['extraArgs'] = [back]
self.backBtn['state'] = DGG.NORMAL
else:
self.backBtn['extraArgs'] = []
self.backBtn['state'] = DGG.DISABLED
def handleFriendsList(self, friendIdArray, nameArray, flags):
self.friends = {}
self.onlineFriends = {}
for i in xrange(len(friendIdArray)):
avatarId = friendIdArray[i]
name = nameArray[i]
self.friends[avatarId] = name
if flags[i] == 1:
self.onlineFriends[avatarId] = name
def enterOff(self):
self.hide()
def exitOff(self):
self.show()
def addFriend(self, name, avatarId):
self.frameForNames.addItem(DirectButton(text=name, extraArgs=[avatarId], command=self.friendClicked, scale=0.035, relief=None, text1_bg=textDownColor, text2_bg=textRolloverColor, text_align=TextNode.ALeft))
return
def friendClicked(self, avatarId):
self.fsm.request('off')
base.localAvatar.panel.makePanel(avatarId)
def resetAll(self):
self.headingText.setText('')
self.frameForNames.removeAndDestroyAllItems()
self.setButtons(None, None)
return
def sortListItems(self):
self.frameForNames['items'].sort(key=lambda x: x['text'])
self.frameForNames.refresh()
def enterAllFriendsList(self):
self.headingText.setText('All\nFriends')
for friendId, name in self.friends.items():
self.addFriend(name, friendId)
self.sortListItems()
self.setButtons(None, 'onlineFriendsList')
return
def exitAllFriendsList(self):
self.resetAll()
def enterOnlineFriendsList(self):
self.headingText.setText('Online\nFriends')
for friendId, name in self.onlineFriends.items():
self.addFriend(name, friendId)
self.sortListItems()
self.setButtons('allFriendsList', None)
return
def exitOnlineFriendsList(self):
self.resetAll()
示例4: CalendarGuiDay
# 需要导入模块: from direct.gui.DirectGui import DirectScrolledList [as 别名]
# 或者: from direct.gui.DirectGui.DirectScrolledList import removeAndDestroyAllItems [as 别名]
#.........这里部分代码省略.........
self.numberWidget['state'] = DirectGuiGlobals.DISABLED
else:
self.numberWidget.setColorScale(1, 1, 1, 1)
if self.myDate.month != self.startDate.month:
self.setColorScale(0.75, 0.75, 0.75, 1.0)
if self.dayClickCallback is not None:
self.numberWidget['state'] = DirectGuiGlobals.DISABLED
else:
self.setColorScale(1, 1, 1, 1)
if self.myDate.date() == curServerDate.date():
self.defaultBox.hide()
self.todayBox.show()
else:
self.defaultBox.show()
self.todayBox.hide()
return
def destroy(self):
if self.dayClickCallback is not None:
self.numberWidget.destroy()
self.dayClickCallback = None
self.notify.debug('desroying %s' % self.myDate)
try:
for item in self.scrollList['items']:
if hasattr(item, 'description') and item.description and hasattr(item.description, 'destroy'):
self.notify.debug('desroying description of item %s' % item)
item.unbind(DGG.ENTER)
item.unbind(DGG.EXIT)
item.description.destroy()
except e:
self.notify.debug('pass %s' % self.myDate)
self.scrollList.removeAndDestroyAllItems()
self.scrollList.destroy()
self.dayButton.destroy()
DirectFrame.destroy(self)
def updateArrowButtons(self):
numItems = 0
try:
numItems = len(self.scrollList['items'])
except e:
numItems = 0
if numItems <= self.scrollList.numItemsVisible:
self.scrollList.incButton.hide()
self.scrollList.decButton.hide()
else:
self.scrollList.incButton.show()
self.scrollList.decButton.show()
def collectTimedEvents(self):
if self.filter == ToontownGlobals.CalendarFilterShowAll or self.filter == ToontownGlobals.CalendarFilterShowOnlyParties:
for party in localAvatar.partiesInvitedTo:
if party.startTime.date() == self.myDate.date():
self.addPartyToScrollList(party)
for party in localAvatar.hostedParties:
if party.startTime.date() == self.myDate.date():
self.addPartyToScrollList(party)
if self.filter == ToontownGlobals.CalendarFilterShowAll or self.filter == ToontownGlobals.CalendarFilterShowOnlyHolidays:
for id, holiday in HolidayGlobals.Holidays.iteritems():
title, description = TTLocalizer.HolidayNamesInCalendar[id]
示例5: CalendarGuiDay
# 需要导入模块: from direct.gui.DirectGui import DirectScrolledList [as 别名]
# 或者: from direct.gui.DirectGui.DirectScrolledList import removeAndDestroyAllItems [as 别名]
#.........这里部分代码省略.........
self.numberWidget.setColorScale(0.5, 0.5, 0.5, 0.5)
self.numberWidget['state'] = DirectGuiGlobals.DISABLED
else:
self.numberWidget.setColorScale(1, 1, 1, 1)
if self.myDate.month != self.startDate.month:
self.setColorScale(0.75, 0.75, 0.75, 1.0)
if self.dayClickCallback is not None:
self.numberWidget['state'] = DirectGuiGlobals.DISABLED
else:
self.setColorScale(1, 1, 1, 1)
if self.myDate.date() == curServerDate.date():
self.defaultBox.hide()
self.todayBox.show()
else:
self.defaultBox.show()
self.todayBox.hide()
def destroy(self):
if self.dayClickCallback is not None:
self.numberWidget.destroy()
self.dayClickCallback = None
self.notify.debug('desroying %s' % self.myDate)
try:
for item in self.scrollList['items']:
if hasattr(item, 'description') and item.description and hasattr(item.description, 'destroy'):
self.notify.debug('desroying description of item %s' % item)
item.unbind(DGG.ENTER)
item.unbind(DGG.EXIT)
item.description.destroy()
except e:
self.notify.debug('pass %s' % self.myDate)
self.scrollList.removeAndDestroyAllItems()
self.scrollList.destroy()
self.dayButton.destroy()
DirectFrame.destroy(self)
def addWeeklyHolidays(self):
if not self.filter == ToontownGlobals.CalendarFilterShowAll and not self.filter == ToontownGlobals.CalendarFilterShowOnlyHolidays:
return
if base.cr.newsManager:
holidays = base.cr.newsManager.getHolidaysForWeekday(self.myDate.weekday())
holidayName = ''
holidayDesc = ''
for holidayId in holidays:
if holidayId in TTLocalizer.HolidayNamesInCalendar:
holidayName = TTLocalizer.HolidayNamesInCalendar[holidayId][0]
holidayDesc = TTLocalizer.HolidayNamesInCalendar[holidayId][1]
else:
holidayName = TTLocalizer.UnknownHoliday % holidayId
self.addTitleAndDescToScrollList(holidayName, holidayDesc)
self.scrollList.refresh()
if config.GetBool('calendar-test-items', 0):
if self.myDate.date() + datetime.timedelta(days=-1) == base.cr.toontownTimeManager.getCurServerDateTime().date():
testItems = ('1:00 AM Party', '2:00 AM CEO', '11:15 AM Party', '5:30 PM CJ', '11:00 PM Party', 'Really Really Long String')
for text in testItems:
newItem = DirectLabel(relief=None, text=text, text_scale=self.ScrollListTextSize, text_align=TextNode.ALeft)
self.scrollList.addItem(newItem)
if self.myDate.date() + datetime.timedelta(days=-2) == base.cr.toontownTimeManager.getCurServerDateTime().date():
testItems = ('1:00 AM Party', '3:00 AM CFO', '11:00 AM Party')
textSize = self.ScrollListTextSize
for text in testItems:
newItem = DirectLabel(relief=None, text=text, text_scale=textSize, text_align=TextNode.ALeft)