本文整理汇总了Python中toontown.parties.PartyUtils.truncateTextOfLabelBasedOnWidth方法的典型用法代码示例。如果您正苦于以下问题:Python PartyUtils.truncateTextOfLabelBasedOnWidth方法的具体用法?Python PartyUtils.truncateTextOfLabelBasedOnWidth怎么用?Python PartyUtils.truncateTextOfLabelBasedOnWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类toontown.parties.PartyUtils
的用法示例。
在下文中一共展示了PartyUtils.truncateTextOfLabelBasedOnWidth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadInvitations
# 需要导入模块: from toontown.parties import PartyUtils [as 别名]
# 或者: from toontown.parties.PartyUtils import truncateTextOfLabelBasedOnWidth [as 别名]
def loadInvitations(self):
EventsPage.notify.debug('loadInvitations')
self.selectedInvitationItem = None
self.invitationPartyList.removeAndDestroyAllItems()
self.invitationActivityList.removeAndDestroyAllItems()
self.invitePartyGoButton['state'] = DirectGuiGlobals.DISABLED
for partyInfo in base.localAvatar.partiesInvitedTo:
if partyInfo.status == PartyGlobals.PartyStatus.Cancelled or partyInfo.status == PartyGlobals.PartyStatus.Finished:
continue
inviteInfo = None
for inviteInfo in base.localAvatar.invites:
if partyInfo.partyId == inviteInfo.partyId:
break
if inviteInfo is None:
EventsPage.notify.error('No invitation info for party id %d' % partyInfo.partyId)
return
if inviteInfo.status == PartyGlobals.InviteStatus.NotRead:
continue
hostName = self.getToonNameFromAvId(partyInfo.hostId)
item = DirectButton(relief=None, text=hostName, text_align=TextNode.ALeft, text_bg=Vec4(0.0, 0.0, 0.0, 0.0), text_scale=0.045, textMayChange=True, command=self.invitePartyClicked)
PartyUtils.truncateTextOfLabelBasedOnWidth(item, hostName, PartyGlobals.EventsPageHostNameMaxWidth)
item['extraArgs'] = [item]
item.setPythonTag('activityIds', partyInfo.getActivityIds())
item.setPythonTag('partyStatus', partyInfo.status)
item.setPythonTag('hostId', partyInfo.hostId)
item.setPythonTag('startTime', partyInfo.startTime)
self.invitationPartyList.addItem(item)
return
示例2: getGuestItem
# 需要导入模块: from toontown.parties import PartyUtils [as 别名]
# 或者: from toontown.parties.PartyUtils import truncateTextOfLabelBasedOnWidth [as 别名]
def getGuestItem(self, name, inviteStatus):
label = DirectLabel(relief=None, text=name, text_scale=0.045, text_align=TextNode.ALeft, textMayChange=True)
dot = DirectFrame(relief=None, geom=self.hostingGui.find('**/questionMark'), pos=(0.5, 0.0, 0.01))
if inviteStatus == PartyGlobals.InviteStatus.Accepted:
dot['geom'] = (self.hostingGui.find('**/checkmark'),)
elif inviteStatus == PartyGlobals.InviteStatus.Rejected:
dot['geom'] = (self.hostingGui.find('**/x'),)
PartyUtils.truncateTextOfLabelBasedOnWidth(label, name, PartyGlobals.EventsPageGuestNameMaxWidth)
dot.reparentTo(label)
return label
示例3: refresh
# 需要导入模块: from toontown.parties import PartyUtils [as 别名]
# 或者: from toontown.parties.PartyUtils import truncateTextOfLabelBasedOnWidth [as 别名]
def refresh(self, partyInfoTupleList):
PublicPartyGui.notify.debug('refresh : partyInfoTupleList = %s' % partyInfoTupleList)
self.selectedItem = None
self.partyList.removeAndDestroyAllItems()
self.activityList.removeAndDestroyAllItems()
self.partyStartButton['state'] = DirectGuiGlobals.DISABLED
sortedList = partyInfoTupleList[:]
def cmp(left, right):
if left[2] < right[2]:
return -1
elif left[2] == right[2]:
if len(left[4]) < len(right[4]):
return -1
elif len(left[4]) == len(right[4]):
return 0
else:
return 1
else:
return 1
sortedList.sort(cmp, reverse=True)
indexToCut = -1
for index, partyTuple in enumerate(sortedList):
numberOfGuests = partyTuple[2]
if numberOfGuests < PartyGlobals.MaxToonsAtAParty:
indexToCut = index
break
if indexToCut > 0:
sortedList = sortedList[indexToCut:] + sortedList[:indexToCut]
for index, partyTuple in enumerate(sortedList):
shardId = partyTuple[0]
zoneId = partyTuple[1]
numberOfGuests = partyTuple[2]
hostName = partyTuple[3]
activityIds = partyTuple[4]
minLeft = partyTuple[5]
item = DirectButton(relief=DGG.RIDGE, borderWidth=(0.01, 0.01), frameSize=(-0.01,
0.45,
-0.015,
0.04), frameColor=self.normalFrameColor, text=hostName, text_align=TextNode.ALeft, text_bg=Vec4(0.0, 0.0, 0.0, 0.0), text_scale=0.045, command=self.partyClicked)
otherInfoWidth = 0.08
numActivities = len(activityIds)
PartyUtils.truncateTextOfLabelBasedOnWidth(item, hostName, PartyGlobals.EventsPageGuestNameMaxWidth)
num = DirectLabel(relief=DGG.RIDGE, borderWidth=(0.01, 0.01), frameSize=(0.0,
otherInfoWidth,
-0.015,
0.04), frameColor=self.normalFrameColor, text='%d' % numberOfGuests, text_align=TextNode.ALeft, text_scale=0.045, text_pos=(0.01, 0, 0), pos=(0.45, 0.0, 0.0))
num.reparentTo(item)
item.numLabel = num
actLabelPos = num.getPos()
actLabelPos.setX(actLabelPos.getX() + otherInfoWidth)
actLabel = DirectLabel(relief=DGG.RIDGE, borderWidth=(0.01, 0.01), frameSize=(0.0,
otherInfoWidth,
-0.015,
0.04), frameColor=self.normalFrameColor, text='%d' % numActivities, text_align=TextNode.ALeft, text_scale=0.045, text_pos=(0.01, 0, 0), pos=actLabelPos)
actLabel.reparentTo(item)
item.actLabel = actLabel
minLabelPos = actLabel.getPos()
minLabelPos.setX(minLabelPos.getX() + otherInfoWidth)
minLabel = DirectLabel(relief=DGG.RIDGE, borderWidth=(0.01, 0.01), frameSize=(0.0,
otherInfoWidth,
-0.015,
0.04), frameColor=self.normalFrameColor, text='%d' % minLeft, text_align=TextNode.ALeft, text_scale=0.045, text_pos=(0.01, 0, 0), pos=minLabelPos)
minLabel.reparentTo(item)
item.minLabel = minLabel
item['extraArgs'] = [item]
item.setPythonTag('shardId', shardId)
item.setPythonTag('zoneId', zoneId)
item.setPythonTag('activityIds', activityIds)
self.partyList.addItem(item)
return