本文整理汇总了Python中horizons.gui.modules.PlayerDataSelection.set_player_name方法的典型用法代码示例。如果您正苦于以下问题:Python PlayerDataSelection.set_player_name方法的具体用法?Python PlayerDataSelection.set_player_name怎么用?Python PlayerDataSelection.set_player_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类horizons.gui.modules.PlayerDataSelection
的用法示例。
在下文中一共展示了PlayerDataSelection.set_player_name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _show_change_player_details_popup
# 需要导入模块: from horizons.gui.modules import PlayerDataSelection [as 别名]
# 或者: from horizons.gui.modules.PlayerDataSelection import set_player_name [as 别名]
def _show_change_player_details_popup(self, game):
"""Shows a dialog where the player can change its name and/or color"""
assigned = [p["color"] for p in NetworkInterface().get_game().get_player_list()
if p["name"] != NetworkInterface().get_client_name()]
unused_colors = set(Color) - set(assigned)
playerdata = PlayerDataSelection(color_palette=unused_colors)
playerdata.set_player_name(NetworkInterface().get_client_name())
playerdata.set_color(NetworkInterface().get_client_color())
dialog = load_uh_widget('set_player_details.xml')
dialog.findChild(name="playerdataselectioncontainer").addChild(playerdata.get_widget())
def _change_playerdata():
NetworkInterface().change_name(playerdata.get_player_name())
NetworkInterface().change_color(playerdata.get_player_color().id)
dialog.hide()
self._update_game_details()
def _cancel():
dialog.hide()
dialog.mapEvents({
OkButton.DEFAULT_NAME: _change_playerdata,
CancelButton.DEFAULT_NAME: _cancel
})
dialog.show()