本文整理汇总了Python中Output.printToWindow方法的典型用法代码示例。如果您正苦于以下问题:Python Output.printToWindow方法的具体用法?Python Output.printToWindow怎么用?Python Output.printToWindow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Output
的用法示例。
在下文中一共展示了Output.printToWindow方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getChoiceFromList
# 需要导入模块: import Output [as 别名]
# 或者: from Output import printToWindow [as 别名]
def getChoiceFromList(player, prompt, list, noChoices=1):
Output.menuWindow.clear()
Output.printToWindow(prompt + '\n', Output.menuWindow)
invalidActions = player._determineValidOptions(list)
freeActions = player._determineFreeOptions(list)
count = 1
indexMapping = {}
for i, currOption in enumerate(list):
if currOption in invalidActions.keys():
Output.printToWindow('{0:2d} - {1} - {2}\n'.format(count, currOption, invalidActions.get(currOption)), Output.menuWindow, colorPair=1)
elif currOption in freeActions.keys():
Output.printToWindow('{0:2d} - {1} - {2}\n'.format(count, currOption, freeActions.get(currOption)), Output.menuWindow, colorPair=2)
indexMapping[count] = currOption
else:
Output.printToWindow('{0:2d} - {1}\n'.format(count, currOption), Output.menuWindow)
indexMapping[count] = currOption
count += 1
chosenOption = []
while True:
for i in range(0, noChoices):
Output.printToWindow('%d of %d : '%(i, noChoices), Output.menuWindow)
choice = int(Output.menuWindow.getstr(2))
#choice -= 48
if choice >= 1 and choice <= len(list):
if choice in indexMapping:
if noChoices > 1:
chosenOption.append(indexMapping[int(choice)])
else:
chosenOption = indexMapping[int(choice)]
if len(chosenOption) > 0:
return chosenOption
示例2: getChoiceFromStack
# 需要导入模块: import Output [as 别名]
# 或者: from Output import printToWindow [as 别名]
def getChoiceFromStack(prompt, currStack, noChoices=1):
Output.menuWindow.clear()
Output.printToWindow(prompt + '\n', Output.menuWindow)
count = 1
indexMapping = {}
for i, currCard in enumerate(currStack.cards):
Output.printToWindow('{0:2d} - {1}\n'.format(count, currCard.visibleName()), Output.menuWindow)
indexMapping[count] = currCard.name
count += 1
chosenCard = []
while True:
for i in range(0, noChoices):
Output.printToWindow('%d of %d : '%(i, noChoices), Output.menuWindow)
choice = int(Output.menuWindow.getstr(2))
#choice -= 48
if choice >= 1 and choice <= len(currStack.cards):
if choice in indexMapping:
chosenCard.append(indexMapping[choice])
if len(chosenCard) > 0:
return chosenCard