当前位置: 首页>>代码示例>>Python>>正文


Python ConfirmDlg.setTitle方法代码示例

本文整理汇总了Python中ConfirmDlg.ConfirmDlg.setTitle方法的典型用法代码示例。如果您正苦于以下问题:Python ConfirmDlg.setTitle方法的具体用法?Python ConfirmDlg.setTitle怎么用?Python ConfirmDlg.setTitle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConfirmDlg.ConfirmDlg的用法示例。


在下文中一共展示了ConfirmDlg.setTitle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from ConfirmDlg import ConfirmDlg [as 别名]
# 或者: from ConfirmDlg.ConfirmDlg import setTitle [as 别名]
class NewAccountDlg:
	""" Called for a new player."""

	def __init__(self, app):
		self.app = app
		self.createUI()
		self.confirmDlg = ConfirmDlg(app)
		self.confirmDlg.setTitle(_("No free starting position"))

	def display(self, caller = None):
		self.caller = caller
		if self.show():
			self.win.show()

	def hide(self):
		self.win.hide()

	def show(self):
		positions = client.cmdProxy.getStartingPositions()
		if not positions:
			# there are no positions -- pop up a dialog
			self.confirmDlg.display(
				_("We are sorry, but there are no starting positions available at this moment. Please, try again later."),
				_("Refresh"), _("Exit"), self.display, self.app.exit
			)
			return False
		items = []
		for objID, name, posType in positions:
			item = ui.Item(name, tObjID = objID, tPosType = posType)
			if posType == STARTPOS_NEWPLAYER:
				item.tPos = _('Independent player')
			elif posType == STARTPOS_AIPLAYER:
				item.tPos = _("Rebel faction")
			elif posType == STARTPOS_PIRATE:
				item.tPos = _("Pirate faction [VIP password needed]")
			else:
				item.tPos = _('Unknown. You cannot use this.')
			items.append(item)
		self.win.vPos.setItems(items)
		return True

	def onSelect(self, widget, action, data):
		if not self.win.vPos.selection:
			self.win.setStatus(_('Select position.'))
			return
		item = self.win.vPos.selection[0]
		if item.tPosType == STARTPOS_NEWPLAYER:
			self.win.setStatus(_('Executing CREATE NEW PLAYER command...'))
			playerID = client.cmdProxy.createNewPlayer(item.tObjID)
			self.win.setStatus(_('Command has been executed.'))
			self.hide()
			if not gdata.mainGameDlg:
				gdata.mainGameDlg = MainGameDlg(self.app)
				gdata.mainGameDlg.display()
			client.updateDatabase(clearDB = 1)
		elif item.tPosType == STARTPOS_AIPLAYER:
			self.win.setStatus(_('Executing TAKE OVER REBEL FACTION command...'))
			playerID = client.cmdProxy.takeOverAIPlayer(item.tObjID)
			self.win.setStatus(_('Command has been executed.'))
			self.hide()
			if not gdata.mainGameDlg:
				gdata.mainGameDlg = MainGameDlg(self.app)
				gdata.mainGameDlg.display()
			client.updateDatabase(clearDB = 1)
		elif item.tPosType == STARTPOS_PIRATE:
			password = self.win.vPassword.text
			if not password:
				self.win.setStatus(_("Supply VIP password, please."))
				return
			self.win.setStatus(_('Executing TAKE OVER PIRATE FACTION command...'))
			try:
				playerID = client.cmdProxy.takeOverPirate(item.tObjID, password)
			except ige.SecurityException:
				self.win.setStatus(_("Supply valid VIP password."))
				return
			self.win.setStatus(_('Command has been executed.'))
			self.hide()
			if not gdata.mainGameDlg:
				gdata.mainGameDlg = MainGameDlg(self.app)
				gdata.mainGameDlg.display()
			client.updateDatabase(clearDB = 1)

	def onCancel(self, widget, action, data):
		self.win.hide()
		if self.caller:
			self.caller.display()
		else:
			self.app.exit()

	def createUI(self):
		w, h = gdata.scrnSize
		self.win = ui.Window(self.app,
			modal = 1,
			movable = 0,
			title = _('Select starting position'),
			rect = ui.Rect((w - 424) / 2, (h - 264) / 2, 424, 264),
			layoutManager = ui.SimpleGridLM(),
			tabChange = True
		)
		ui.Listbox(self.win, layout = (0, 0, 21, 10), id = 'vPos',
#.........这里部分代码省略.........
开发者ID:Lukc,项目名称:ospace-lukc,代码行数:103,代码来源:NewAccountDlg.py

示例2: __init__

# 需要导入模块: from ConfirmDlg import ConfirmDlg [as 别名]
# 或者: from ConfirmDlg.ConfirmDlg import setTitle [as 别名]
class PlayerSelectDlg:
    """ Called for selection of active or picking a new player."""

    def __init__(self, app):
        self.app = app
        self.wantsNew = False
        self.needsPassword = False
        self.previousSelection = None # this is to fix connection lost/relog usability issue
        self.createUI()
        self.passwordDlg = PasswordDlg(app)
        self.confirmDlg = ConfirmDlg(app)
        self.confirmDlg.setTitle(_("No free starting position"))

    def display(self, caller = None):
        self.caller = caller
        if gdata.mainGameDlg and self.previousSelection:
            # this means connection dropped and we relogged
            # let's go straight to the previously selected game
            self._selectPlayer(self.previousSelection)
            return
        if self.show():
            self.win.show()

    def hide(self):
        self.win.hide()

    def show(self):
        items = []
        items.extend(self.showActivePlayers())
        if self.wantsNew:
            items.extend(self.showStartPositions())
        self.win.vPos.setItems(items)
        return True

    def showActivePlayers(self):
        dataActive = client.cmdProxy.getActivePositions()
        items = []
        for playerID, galaxyName, playerType in dataActive:
            item = ui.Item(galaxyName, type = 'Active', tObjID = playerID, tPosType = Const.PLAYER_SELECT_CONTINUE)
            if playerType == Const.T_PLAYER:
                item.tPos = _('Continue playing.')
            elif playerType == Const.T_PIRPLAYER:
                item.tPos = _('Yarr!')
            else:
                item.tPos = _('Unknown type of player.')
            items.append(item)
        if not items:
            item = ui.Item('', type = '', tObjID = 'No active players', tPosType = None)
            item.tPos = 'No Active Player'
            items.append(item)
        return items

    def showStartPositions(self):
        dataStart = client.cmdProxy.getStartingPositions()
        items = []
        for objID, galaxyName, posType in dataStart:
            item = ui.Item(galaxyName, type = _('Open'), tObjID = objID, tPosType = posType)
            if posType == Const.PLAYER_SELECT_NEWPLAYER:
                item.tPos = _('Independent player')
            elif posType == Const.PLAYER_SELECT_AIPLAYER:
                item.tPos = _("Rebel faction")
            elif posType == Const.PLAYER_SELECT_PIRATE:
                item.tPos = _("Pirate faction [VIP password needed]")
            else:
                item.tPos = _('Unknown. You cannot use this.')
            items.append(item)
        return items

    def onSelect(self, widget, action, data):
        if not self.win.vPos.selection:
            self.win.setStatus(_('Select position.'))
            return
        item = self.win.vPos.selection[0]
        if item.tPosType == Const.PLAYER_SELECT_CONTINUE:
            playerID = item.tObjID
        elif item.tPosType == Const.PLAYER_SELECT_NEWPLAYER:
            self.win.setStatus(_('Executing CREATE NEW PLAYER command...'))
            playerID = client.cmdProxy.createNewPlayer(item.tObjID)
            self.win.setStatus(_('Command has been executed.'))
        elif item.tPosType == Const.PLAYER_SELECT_AIPLAYER:
            self.win.setStatus(_('Executing TAKE OVER REBEL FACTION command...'))
            playerID = client.cmdProxy.takeOverAIPlayer(item.tObjID)
            self.win.setStatus(_('Command has been executed.'))
        elif item.tPosType == Const.PLAYER_SELECT_PIRATE:
            playerID = self.passwordDlg.display(lambda x: self._takeOverPirate(item.tObjID, x))
            return
        else:
            return
        self._selectPlayer(playerID)

    def _takeOverPirate(self, positionID, password):
        self.win.setStatus(_('Executing TAKE OVER PIRATE FACTION command...'))
        try:
            playerID = client.cmdProxy.takeOverPirate(positionID, password)
        except ige.SecurityException:
            self.win.setStatus(_("Supply valid VIP password."))
            return
        self.win.setStatus(_('Command has been executed.'))
        self._selectPlayer(playerID)

#.........这里部分代码省略.........
开发者ID:ospaceteam,项目名称:outerspace,代码行数:103,代码来源:PlayerSelectDlg.py


注:本文中的ConfirmDlg.ConfirmDlg.setTitle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。