本文整理汇总了Python中direct.gui.DirectGui.DirectScrolledList.addItem方法的典型用法代码示例。如果您正苦于以下问题:Python DirectScrolledList.addItem方法的具体用法?Python DirectScrolledList.addItem怎么用?Python DirectScrolledList.addItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类direct.gui.DirectGui.DirectScrolledList
的用法示例。
在下文中一共展示了DirectScrolledList.addItem方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CalendarGuiDay
# 需要导入模块: from direct.gui.DirectGui import DirectScrolledList [as 别名]
# 或者: from direct.gui.DirectGui.DirectScrolledList import addItem [as 别名]
#.........这里部分代码省略.........
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:
newItem = DirectLabel(relief=None, text=text, text_scale=textSize, text_align=TextNode.ALeft)
self.scrollList.addItem(newItem)
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):
self.timedEvents = []
if self.filter == ToontownGlobals.CalendarFilterShowAll or self.filter == ToontownGlobals.CalendarFilterShowOnlyParties:
for party in localAvatar.partiesInvitedTo:
if party.startTime.date() == self.myDate.date():
self.partiesInvitedToToday.append(party)
self.timedEvents.append((party.startTime.time(), party))
for party in localAvatar.hostedParties:
if party.startTime.date() == self.myDate.date():
示例2: PartyEditor
# 需要导入模块: from direct.gui.DirectGui import DirectScrolledList [as 别名]
# 或者: from direct.gui.DirectGui.DirectScrolledList import addItem [as 别名]
class PartyEditor(DirectObject, FSM):
notify = directNotify.newCategory('PartyEditor')
def __init__(self, partyPlanner, parent):
FSM.__init__(self, self.__class__.__name__)
self.partyPlanner = partyPlanner
self.parent = parent
self.partyEditorGrid = PartyEditorGrid(self)
self.currentElement = None
self.defaultTransitions = {'Hidden': ['Idle', 'Cleanup'],
'Idle': ['DraggingElement', 'Hidden', 'Cleanup'],
'DraggingElement': ['Idle',
'DraggingElement',
'Hidden',
'Cleanup'],
'Cleanup': []}
self.initElementList()
self.initPartyClock()
self.initTrashCan()
return
def initElementList(self):
self.activityIconsModel = loader.loadModel('phase_4/models/parties/eventSignIcons')
self.decorationModels = loader.loadModel('phase_4/models/parties/partyDecorations')
pos = self.partyPlanner.gui.find('**/step_05_activitiesIcon_locator').getPos()
self.elementList = DirectScrolledList(parent=self.parent, relief=None, decButton_image=(self.partyPlanner.gui.find('**/activitiesButtonUp_up'),
self.partyPlanner.gui.find('**/activitiesButtonUp_down'),
self.partyPlanner.gui.find('**/activitiesButtonUp_rollover'),
self.partyPlanner.gui.find('**/activitiesButtonUp_inactive')), decButton_relief=None, decButton_pos=(-0.05, 0.0, -0.38), incButton_image=(self.partyPlanner.gui.find('**/activitiesButtonDown_up'),
self.partyPlanner.gui.find('**/activitiesButtonDown_down'),
self.partyPlanner.gui.find('**/activitiesButtonDown_rollover'),
self.partyPlanner.gui.find('**/activitiesButtonDown_inactive')), incButton_relief=None, incButton_pos=(-0.05, 0.0, -0.94), itemFrame_pos=(pos[0], pos[1], pos[2] + 0.04), itemFrame_relief=None, numItemsVisible=1, items=[])
holidayIds = base.cr.newsManager.getHolidayIdList()
isWinter = ToontownGlobals.WINTER_DECORATIONS in holidayIds or ToontownGlobals.WACKY_WINTER_DECORATIONS in holidayIds
isVictory = ToontownGlobals.VICTORY_PARTY_HOLIDAY in holidayIds
isValentine = ToontownGlobals.VALENTINES_DAY in holidayIds
for activityId in PartyGlobals.PartyEditorActivityOrder:
if not isVictory and activityId in PartyGlobals.VictoryPartyActivityIds or not isWinter and activityId in PartyGlobals.WinterPartyActivityIds or not isValentine and activityId in PartyGlobals.ValentinePartyActivityIds:
pass
elif isVictory and activityId in PartyGlobals.VictoryPartyReplacementActivityIds or isWinter and activityId in PartyGlobals.WinterPartyReplacementActivityIds or isValentine and activityId in PartyGlobals.ValentinePartyReplacementActivityIds:
pass
else:
pele = PartyEditorListElement(self, activityId)
self.elementList.addItem(pele)
if activityId == PartyGlobals.ActivityIds.PartyClock:
self.partyClockElement = pele
for decorationId in PartyGlobals.DecorationIds:
if not isVictory and decorationId in PartyGlobals.VictoryPartyDecorationIds or not isWinter and decorationId in PartyGlobals.WinterPartyDecorationIds or not isValentine and decorationId in PartyGlobals.ValentinePartyDecorationIds:
pass
elif isVictory and decorationId in PartyGlobals.VictoryPartyReplacementDecorationIds or isValentine and decorationId in PartyGlobals.ValentinePartyReplacementDecorationIds:
pass
elif decorationId in PartyGlobals.TTIUnreleasedDecor:
pass
else:
pele = PartyEditorListElement(self, decorationId, isDecoration=True)
self.elementList.addItem(pele)
self.elementList.refresh()
self.elementList['command'] = self.scrollItemChanged
return
def initPartyClock(self):
self.partyClockElement.buyButtonClicked((8, 7))
def initTrashCan(self):
trashcanGui = loader.loadModel('phase_3/models/gui/trashcan_gui')
self.trashCanButton = DirectButton(parent=self.parent, relief=None, pos=Point3(*PartyGlobals.TrashCanPosition), scale=PartyGlobals.TrashCanScale, geom=(trashcanGui.find('**/TrashCan_CLSD'),
trashcanGui.find('**/TrashCan_OPEN'),
trashcanGui.find('**/TrashCan_RLVR'),
trashcanGui.find('**/TrashCan_RLVR')), command=self.trashCanClicked)
self.trashCanButton.bind(DirectGuiGlobals.ENTER, self.mouseEnterTrash)
self.trashCanButton.bind(DirectGuiGlobals.EXIT, self.mouseExitTrash)
self.mouseOverTrash = False
self.oldInstructionText = ''
self.trashCanLastClickedTime = 0
return
def scrollItemChanged(self):
if not self.elementList['items']:
return
self.currentElement = self.elementList['items'][self.elementList.getSelectedIndex()]
self.elementList['items'][self.elementList.getSelectedIndex()].elementSelectedFromList()
if self.elementList['items'][self.elementList.getSelectedIndex()].isDecoration:
self.partyPlanner.instructionLabel['text'] = TTLocalizer.PartyPlannerEditorInstructionsClickedElementDecoration
else:
self.partyPlanner.instructionLabel['text'] = TTLocalizer.PartyPlannerEditorInstructionsClickedElementActivity
def listElementClicked(self):
self.request('DraggingElement')
def listElementReleased(self):
self.request('Idle', True)
def trashCanClicked(self):
currentTime = time.time()
if currentTime - self.trashCanLastClickedTime < 0.2:
self.clearPartyGrounds()
self.trashCanLastClickedTime = time.time()
#.........这里部分代码省略.........
示例3: Highscore
# 需要导入模块: from direct.gui.DirectGui import DirectScrolledList [as 别名]
# 或者: from direct.gui.DirectGui.DirectScrolledList import addItem [as 别名]
class Highscore():
def __init__(self):
home = os.path.expanduser("~")
quickJNRDir = os.path.join(home, ".quickShooter")
if not os.path.exists(quickJNRDir): os.makedirs(quickJNRDir)
self.highscorefile = os.path.join(quickJNRDir, "highscore.txt")
self.highscore = []
if not os.path.exists(self.highscorefile):
with open(self.highscorefile, "w") as f:
f.write("""Foxy;4000
Wolf;3500
Coon;3000
Kitty;2020
Ferret;2000
Lynx;1700
Lion;1280
Tiger;800
Birdy;450
Fishy;250""")
with open(self.highscorefile, "r+") as f:
data = f.readlines()
for line in data:
name = line.split(";")[0]
pts = line.split(";")[1]
self.highscore.append([name, pts])
self.lstHighscore = DirectScrolledList(
frameSize = (-1, 1, -0.6, 0.6),
frameColor = (0,0,0,0.5),
pos = (0, 0, 0),
numItemsVisible = 10,
itemMakeFunction = self.__makeListItem,
itemFrame_frameSize = (-0.9, 0.9, 0.0, -1),
itemFrame_color = (1, 1, 1, 0),
itemFrame_pos = (0, 0, 0.5))
self.btnBack = DirectButton(
# size of the button
scale = (0.15, 0.15, 0.15),
text = "Back",
# set no relief
relief = None,
frameColor = (0,0,0,0),
# No sink in when press
pressEffect = False,
# position on the window
pos = (0.2, 0, 0.1),
# the event which is thrown on clickSound
command = self.btnBack_Click,
# sounds that should be played
rolloverSound = None,
clickSound = None)
self.btnBack.setTransparency(1)
self.btnBack.reparentTo(base.a2dBottomLeft)
self.refreshList()
self.hide()
def show(self):
self.lstHighscore.show()
self.btnBack.show()
def hide(self):
self.lstHighscore.hide()
self.btnBack.hide()
def writeHighscore(self):
self.__sortHigscore()
with open(self.highscorefile, "w") as f:
for entry in self.highscore:
f.write("{0};{1}".format(entry[0], entry[1]))
def refreshList(self):
self.__sortHigscore()
self.lstHighscore.removeAllItems()
for entry in self.highscore:
self.lstHighscore.addItem("{0};{1}".format(entry[0], entry[1]))
def __makeListItem(self, highscoreItem, stuff, morestuff):
name = highscoreItem.split(";")[0]
pts = highscoreItem.split(";")[1]
# left
l = -0.9
# right
r = 0.9
itemFrame = DirectFrame(
frameColor=(1, 1, 1, 0.5),
frameSize=(l, r, -0.1, 0),
relief=DGG.SUNKEN,
borderWidth=(0.01, 0.01),
pos=(0, 0, 0))
lblName = DirectLabel(
pos=(l + 0.01, 0, -0.07),
text=name,
#.........这里部分代码省略.........
示例4: CalendarGuiDay
# 需要导入模块: from direct.gui.DirectGui import DirectScrolledList [as 别名]
# 或者: from direct.gui.DirectGui.DirectScrolledList import addItem [as 别名]
#.........这里部分代码省略.........
self.addTitleAndDescToScrollList(title, description)
elif 'startMonth' in holiday or 'startDay' in holiday:
startDate = HolidayGlobals.getStartDate(holiday, self.myDate)
endDate = HolidayGlobals.getEndDate(holiday, self.myDate)
if self.isDateMatch(self.myDate, startDate):
if self.isDateMatch(startDate, endDate):
description = '%s. %s' % (title, description)
else:
description = '%s. %s %s %s' % (title, description, TTLocalizer.CalendarEndsAt, endDate.strftime('%b %d'))
self.addTitleAndDescToScrollList(title, description)
elif self.isDateMatch(self.myDate, endDate):
title = '%s %s' % (TTLocalizer.CalendarEndOf, title)
description = '%s. %s %s' % (title, TTLocalizer.CalendarStartedOn, startDate.strftime('%b %d'))
self.addTitleAndDescToScrollList(title, description)
def isDateMatch(self, date1, date2):
return date1.day == date2.day and date1.month == date2.month
def addTitleAndDescToScrollList(self, title, desc):
textSize = self.ScrollListTextSize
descTextSize = 0.05
newItem = DirectButton(relief=None, text=title, text_scale=textSize, text_align=TextNode.ALeft, rolloverSound=None, clickSound=None, pressEffect=0, command=self.__clickedOnScrollItem)
scrollItemHeight = newItem.getHeight()
descUnderItemZAdjust = scrollItemHeight * descTextSize / textSize
descUnderItemZAdjust = max(0.0534, descUnderItemZAdjust)
descUnderItemZAdjust = -descUnderItemZAdjust
descZAdjust = descUnderItemZAdjust
newItem.description = DirectLabel(parent=newItem, pos=(0.115, 0, descZAdjust), text='', text_wordwrap=15, pad=(0.02, 0.02), text_scale=descTextSize, text_align=TextNode.ACenter, textMayChange=0)
newItem.description.checkedHeight = False
newItem.description.setBin('gui-popup', 0)
newItem.description.hide()
newItem.bind(DGG.ENTER, self.enteredTextItem, extraArgs=[newItem, desc, descUnderItemZAdjust])
newItem.bind(DGG.EXIT, self.exitedTextItem, extraArgs=[newItem])
self.scrollList.addItem(newItem)
return
def exitedTextItem(self, newItem, mousepos):
newItem.description.hide()
def enteredTextItem(self, newItem, descText, descUnderItemZAdjust, mousePos):
if not newItem.description.checkedHeight:
newItem.description.checkedHeight = True
newItem.description['text'] = descText
bounds = newItem.description.getBounds()
descHeight = newItem.description.getHeight()
scrollItemHeight = newItem.getHeight()
descOverItemZAdjust = descHeight - scrollItemHeight / 2.0
descZPos = self.getPos(aspect2d)[2] + descUnderItemZAdjust - descHeight
if descZPos < -1.0:
newItem.description.setZ(descOverItemZAdjust)
descWidth = newItem.description.getWidth()
brightFrame = loader.loadModel('phase_4/models/parties/tt_m_gui_sbk_calendar_popUp_bg')
newItem.description['geom'] = brightFrame
newItem.description['geom_scale'] = (descWidth, 1, descHeight)
descGeomZ = (bounds[2] - bounds[3]) / 2.0
descGeomZ += bounds[3]
newItem.description['geom_pos'] = (0, 0, descGeomZ)
newItem.description.show()
def addPartyToScrollList(self, party):
textSize = self.ScrollListTextSize
descTextSize = 0.05
partyTitle = myStrftime(party.startTime)
partyTitle = partyTitle + ' ' + TTLocalizer.EventsPageCalendarTabParty
textSize = self.ScrollListTextSize
descTextSize = 0.05
示例5: FriendsList
# 需要导入模块: from direct.gui.DirectGui import DirectScrolledList [as 别名]
# 或者: from direct.gui.DirectGui.DirectScrolledList import addItem [as 别名]
class FriendsList(DirectFrame):
notify = DirectNotifyGlobal.directNotify.newCategory('FriendsList')
def __init__(self):
DirectFrame.__init__(self, parent=base.a2dTopRight, pos=(-0.25, 0.0, -0.46))
gui = loader.loadModel('phase_3.5/models/gui/friendslist_gui.bam')
self['image'] = gui.find('**/FriendsBox_Open')
self.headingText = OnscreenText(text='', parent=self, pos=(0.01, 0.2), fg=(0.1, 0.1, 0.4, 1.0), scale=0.04)
self.frameForNames = DirectScrolledList(frameSize=(0.0, 0.35, 0, 0.35), incButton_geom=(gui.find('**/FndsLst_ScrollUp'),
gui.find('**/FndsLst_ScrollDN'),
gui.find('**/FndsLst_ScrollUp_Rllvr'),
gui.find('**/FndsLst_ScrollUp')), incButton_relief=None, incButton_hpr=(0, 0, 180), incButton_pos=(0.17, 0, -0.04), decButton_geom=(gui.find('**/FndsLst_ScrollUp'),
gui.find('**/FndsLst_ScrollDN'),
gui.find('**/FndsLst_ScrollUp_Rllvr'),
gui.find('**/FndsLst_ScrollUp')), decButton_relief=None, decButton_pos=(0.17, 0, 0.395), pos=(-0.1625, 0.0, -0.27), parent=self, numItemsVisible=9, forceHeight=0.04, itemFrame_frameSize=(-0.15, 0.15, 0, -0.35), itemFrame_pos=(0, 0, 0.3275), itemFrame_relief=None, relief=None)
self.fwdBtn = DirectButton(geom=(gui.find('**/Horiz_Arrow_UP'),
gui.find('**/Horiz_Arrow_DN'),
gui.find('**/Horiz_Arrow_Rllvr'),
gui.find('**/Horiz_Arrow_UP')), relief=None, parent=self, pos=(0.17, 0.0, -0.38), command=self.doState)
self.backBtn = DirectButton(geom=(gui.find('**/Horiz_Arrow_UP'),
gui.find('**/Horiz_Arrow_DN'),
gui.find('**/Horiz_Arrow_Rllvr'),
gui.find('**/Horiz_Arrow_UP')), relief=None, parent=self, pos=(-0.15, 0.0, -0.38), hpr=(180, 0, 0), command=self.doState)
self.closeBtn = DirectButton(geom=CIGlobals.getCancelBtnGeom(), relief=None, parent=self, command=self.exitClicked)
self.closeBtn.setPos(0.015, 0.0, -0.375)
gui.removeNode()
del gui
self.hide()
self.friends = {}
self.onlineFriends = {}
self.fsm = ClassicFSM.ClassicFSM('FriendsList', [State.State('off', self.enterOff, self.exitOff), State.State('onlineFriendsList', self.enterOnlineFriendsList, self.exitOnlineFriendsList), State.State('allFriendsList', self.enterAllFriendsList, self.exitAllFriendsList)], 'off', 'off')
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('')
#.........这里部分代码省略.........
示例6: MenuOptions
# 需要导入模块: from direct.gui.DirectGui import DirectScrolledList [as 别名]
# 或者: from direct.gui.DirectGui.DirectScrolledList import addItem [as 别名]
#.........这里部分代码省略.........
self.accept(
keyboardKey,
setSelectedKey,
[keyboardKey])
# set up a dialog wich will ask for the new key for the chosen action
self.keySelectDialog = OkCancelDialog(
dialogName = "OkCancelDialog",
text = "{0}: {1}".format(key, value[0]),
fadeScreen = 1,
command = setKey
)
# show the dialog
self.keySelectDialog.show()
# add the change button to change the key of the action
itemBtnChange = DirectButton(
text = _("change"),
scale = 0.05,
pos = (0.5, 0, -0.05),
command = changeKey,
extraArgs = [key, value]
)
itemBtnChange.reparentTo(itemFrame)
# add the label wich will show the name and key of the action
itemText = DirectLabel(
text = "{0} - {1}".format(key, value[0]),
text_scale = 0.06,
text_align = TextNode.ALeft,
pos = (-0.88, 0, -0.06))
itemText.reparentTo(itemFrame)
# finaly add the item to the list
self.controlsList.addItem(itemFrame)
def show(self):
self.setText()
self.showBase()
def showGeneralTab(self):
# set the selected language in the textbox
if self.engine.settings.selectedLanguage == "de-DE":
self.cmbLanguage.set(0, False)
elif self.engine.settings.selectedLanguage == "ru-RU":
self.cmbLanguage.set(2, False)
elif self.engine.settings.selectedLanguage == "fr-FR":
self.cmbLanguage.set(3, False)
else:
self.cmbLanguage.set(1, False)
res = str(self.engine.settings.windowSize[0]) + "x" + str(self.engine.settings.windowSize[1])
i = 0
for item in self.cmbResolution["items"]:
if item == res:
self.cmbResolution.set(i, False)
i += 1
self.sliderGraphicQuality["value"] = self.engine.settings.graphicquality
self.sliderVolume["value"] = self.engine.settings.volume
#self.cbVolumeMute["indicatorValue"] = settings.muted
self.cbVolumeMute["isChecked"] = not self.engine.settings.muted
self.cbVolumeMute.commandFunc(None)
示例7: MainMenu
# 需要导入模块: from direct.gui.DirectGui import DirectScrolledList [as 别名]
# 或者: from direct.gui.DirectGui.DirectScrolledList import addItem [as 别名]
class MainMenu():
def __init__(self, showbase):
self.showbase = showbase
self.status = OnscreenText(text = "", pos = Vec3(0, -0.35, 0), scale = 0.05, fg = (1, 0, 0, 1), align = TextNode.ACenter, mayChange = True)
self.background = DirectFrame(
frameSize = (-1, 1, -1, 1),
frameTexture = 'media/gui/mainmenu/menu.png',
parent = self.showbase.render2d,
)
self.title = OnscreenText(
text = 'Main Menu',
fg = (1, 1, 1, 1),
parent = self.background,
pos = (-0.6, 0.1),
scale = 0.06
)
self.ip = '127.0.0.1' # Should make this write to file... so that the user can save ip's...
# yep thats a good idea, there will be a few things i guess that need to be done like this
# like settings and keys and whatnot
# Buttons
self.buttons = []
serverButtons = Vec3(-0.60, 0, -0.79)
# Host
self.params = ['3', '8']
p = serverButtons + Vec3(-0.25, 0, 0)
self.hostButton = DirectButton(text = 'Host', pos = p, scale = 0.048, relief = DGG.GROOVE, command = self.showbase.hostGame, extraArgs = [self.params])
self.buttons.append(self.hostButton)
# Join
p = serverButtons + Vec3(0.0, 0.0, 0.0)
self.joinButton = DirectButton(text = 'Join', pos = p, scale = 0.048, relief = DGG.GROOVE, command = self.joinServer)
self.buttons.append(self.joinButton)
# Refresh
if self.showbase.online:
p = serverButtons + Vec3(0.25, 0, 0)
self.refreshButton = DirectButton(text = "Refresh", pos = p, scale = 0.048, relief = DGG.GROOVE, command = self.refreshStart)
self.buttons.append(self.refreshButton)
self.refreshStart()
chatFrameCenter = (0.0, 0.325)
chatFrameSize = (2.5, 1.2)
self.chat = DirectFrame(
frameColor = (0, 0, 0, 1),
frameSize = (chatFrameSize[0] / 2, -chatFrameSize[0] / 2, chatFrameSize[1] / 2, -chatFrameSize[1] / 2),
pos = (chatFrameCenter[0], 0, chatFrameCenter[1])
)
channelFrameSize = (chatFrameSize[0] / 4, chatFrameSize[1])
channelFrameCenter = (- chatFrameSize[0] / 2 + channelFrameSize[0] / 2, 0)
numItemsVisible = 8
itemHeight = channelFrameSize[1] / (numItemsVisible + 1)
self.channels = DirectScrolledList(
parent = self.chat,
pos = (channelFrameCenter[0], 0, channelFrameCenter[1]),
frameSize = (-channelFrameSize[0] / 2, channelFrameSize[0] / 2, channelFrameSize[1] / 2, -channelFrameSize[1] / 2),
frameColor = (1, 0, 0, 0.5),
numItemsVisible = numItemsVisible,
forceHeight = itemHeight,
#itemFrame_frameSize = (-channelFrameSize[0] / 2.1, channelFrameSize[0] / 2.1, itemHeight, -channelFrameSize[1] + itemHeight),
itemFrame_pos = (0, 0, channelFrameSize[1] / 2 - itemHeight),
decButton_pos = (-0.2, 0, channelFrameCenter[1] - channelFrameSize[1] / 2 + itemHeight / 4),
decButton_text = 'Prev',
decButton_text_scale = 0.05,
decButton_borderWidth = (0.005, 0.005),
incButton_pos = (0.2, 0, channelFrameCenter[1] - channelFrameSize[1] / 2 + itemHeight / 4),
incButton_text = 'Next',
incButton_text_scale = 0.05,
incButton_borderWidth = (0.005, 0.005),
)
b1 = DirectButton(text = ("Button1", "click!", "roll", "disabled"),
text_scale = 0.1, borderWidth = (0.01, 0.01),
relief = 2)
b2 = DirectButton(text = ("Button2", "click!", "roll", "disabled"),
text_scale = 0.1, borderWidth = (0.01, 0.01),
relief = 2)
l1 = DirectLabel(text = "Test1", text_scale = 0.1)
l2 = DirectLabel(text = "Test2", text_scale = 0.1)
l3 = DirectLabel(text = "Test3", text_scale = 0.1)
self.channels.addItem(b1)
self.channels.addItem(b2)
self.channels.addItem(l1)
self.channels.addItem(l2)
self.channels.addItem(l3)
for fruit in ['apple', 'pear', 'banana', 'orange', 'cake', 'chocolate']:
l = DirectLabel(text = fruit, text_scale = 0.1)
self.channels.addItem(l)
# need to add the chat stuff
# i guess have like a chat manager which will hold an array of 'chat_instances'
#.........这里部分代码省略.........
示例8: CalendarGuiDay
# 需要导入模块: from direct.gui.DirectGui import DirectScrolledList [as 别名]
# 或者: from direct.gui.DirectGui.DirectScrolledList import addItem [as 别名]
#.........这里部分代码省略.........
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)
self.scrollList.addItem(newItem)
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):
self.timedEvents = []
if self.filter == ToontownGlobals.CalendarFilterShowAll or self.filter == ToontownGlobals.CalendarFilterShowOnlyParties:
for party in localAvatar.partiesInvitedTo:
if party.startTime.date() == self.myDate.date():
self.partiesInvitedToToday.append(party)
self.timedEvents.append((party.startTime.time(), party))
for party in localAvatar.hostedParties:
if party.startTime.date() == self.myDate.date():
示例9: GroupTrackerPage
# 需要导入模块: from direct.gui.DirectGui import DirectScrolledList [as 别名]
# 或者: from direct.gui.DirectGui.DirectScrolledList import addItem [as 别名]
#.........这里部分代码省略.........
self.updateGroupInfo(groupWidget)
return False
return True
def setGroups(self, groups):
''' Calls updateGroupList '''
# Clear our Group Widgets
for group in self.groupWidgets:
group.destroy()
self.groupWidgets = []
wantReconsiderInfo = True
# Create a new group widget for each group
for group in groups:
if not group[GroupTrackerGlobals.SHOW] or len(group[GroupTrackerGlobals.MEMBER_IDS]) == 0:
continue # We are using this to see if this group is dead or if someone doesnt want it up
leaderId = 0
for i, g in base.cr.globalGroupTracker.leader2Group.items():
if g == group:
leaderId = i
if not leaderId:
continue
leaderName = group[GroupTrackerGlobals.LEADER_NAME]
shardName = group[GroupTrackerGlobals.SHARD_NAME]
category = group[GroupTrackerGlobals.CATEGORY]
memberIds = group[GroupTrackerGlobals.MEMBER_IDS]
memberNames = group[GroupTrackerGlobals.MEMBER_NAMES]
groupWidget = GroupTrackerGroup(parent=self, leaderId=leaderId, leaderName=leaderName, shardName=shardName, category=category, memberIds=memberIds, memberNames=memberNames)
groupWidget.bind(DGG.WITHIN, self.updateGroupInfoEventHandle, extraArgs=[groupWidget])
self.groupWidgets.append(groupWidget)
if wantReconsiderInfo:
wantReconsiderInfo = self.reconsiderGroupInfo(groupWidget)
# Edge case where a group that was removed, info might remain on the screen if it didn't exist any more
if wantReconsiderInfo:
self.clearGroupInfo()
# There are no groups, hide the information
if len(self.groupWidgets) == 0:
self.displayNoGroups()
self.updateGroupList()
def updateGroupList(self):
self.statusMessage.hide()
if self.scrollList is None:
return
# Clear the Group Listing
for item in self.scrollList['items']:
if item:
self.scrollList.removeItem(item, refresh=True)
self.scrollList['items'] = []
# Re-populate the Group Listing
for groupWidget in self.groupWidgets:
self.scrollList.addItem(groupWidget, refresh=True)
if len(self.groupWidgets) == 0:
self.displayNoGroups()
def updatePlayerList(self):
if self.playerList is None:
return
# Clear the Player Listing
for item in self.playerList['items']:
if item:
self.playerList.removeItem(item)
self.playerList['items'] = []
# Re-Populate the List
for playerWidget in self.playerWidgets:
self.playerList.addItem(playerWidget)
def toggleWantGroup(self):
if settings.get('grouptracker', False):
settings['grouptracker'] = False
base.cr.globalGroupTracker.showMe(False)
else:
settings['grouptracker'] = True
base.cr.globalGroupTracker.showMe(True)
base.localAvatar.wantGroupTracker()
base.localAvatar.wantGroupTracker() # Updates the ai toon so the boarding group AI could know what he wants
self.updateWantGroupButton()
def updateWantGroupButton(self):
if settings.get('grouptracker', False):
self.wantGroupToggle['text'] = 'Hide Me'
else:
self.wantGroupToggle['text'] = 'Show Me'
def doNothing(self):
pass