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


Python InfoBarMessage.add_button方法代码示例

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


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

示例1: offerError

# 需要导入模块: from pychess.widgets.InfoBar import InfoBarMessage [as 别名]
# 或者: from pychess.widgets.InfoBar.InfoBarMessage import add_button [as 别名]
    def offerError(self, offer, error):
        log.debug("Human.offerError: self=%s error=%s %s" %
                  (self, error, offer))
        assert offer.type in ACTION_NAMES
        actionName = ACTION_NAMES[offer.type]
        if error == ACTION_ERROR_NONE_TO_ACCEPT:
            heading = _("Unable to accept %s") % actionName.lower()
            text = _("Probably because it has been withdrawn.")
        elif error == ACTION_ERROR_NONE_TO_DECLINE or \
                error == ACTION_ERROR_NONE_TO_WITHDRAW:
            # If the offer was not there, it has probably already been either
            # declined or withdrawn.
            return
        else:
            heading = _("%s returns an error") % actionName
            text = ERROR_MESSAGES[error]

        content = InfoBar.get_message_content(heading, text,
                                              Gtk.STOCK_DIALOG_WARNING)

        def response_cb(infobar, response, message):
            message.dismiss()

        message = InfoBarMessage(Gtk.MessageType.WARNING, content, response_cb)
        message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE,
                                                Gtk.ResponseType.CANCEL))
        self.gmwidg.showMessage(message)
开发者ID:TPNguyen,项目名称:pychess,代码行数:29,代码来源:Human.py

示例2: response_cb

# 需要导入模块: from pychess.widgets.InfoBar import InfoBarMessage [as 别名]
# 或者: from pychess.widgets.InfoBar.InfoBarMessage import add_button [as 别名]
 def response_cb (infobar, response, message):
     if response == gtk.RESPONSE_ACCEPT:
         #self.emit("offer", offer)
     message.dismiss()
 message = InfoBarMessage(gtk.MESSAGE_INFO, content, response_cb)
 message.add_button(InfoBarMessageButton(_("Resend"), gtk.RESPONSE_ACCEPT))
 message.add_button(InfoBarMessageButton(gtk.STOCK_CLOSE, gtk.RESPONSE_CANCEL))
 self._show_message(message)
开发者ID:btrent,项目名称:knave,代码行数:10,代码来源:Human.py

示例3: hurry

# 需要导入模块: from pychess.widgets.InfoBar import InfoBarMessage [as 别名]
# 或者: from pychess.widgets.InfoBar.InfoBarMessage import add_button [as 别名]
 def hurry (self):
     title = _("Your opponent asks you to hurry!")
     text = _("Generally this means nothing, as the game is time-based, but if you want to please your opponent, perhaps you should get going.")
     content = InfoBar.get_message_content(title, text, Gtk.STOCK_DIALOG_INFO)
     def response_cb (infobar, response, message):
         message.dismiss()
     message = InfoBarMessage(Gtk.MessageType.INFO, content, response_cb)
     message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE, Gtk.ResponseType.CANCEL))
     self.gmwidg.showMessage(message)
开发者ID:sally0813,项目名称:pychess,代码行数:11,代码来源:Human.py

示例4: offerWithdrawn

# 需要导入模块: from pychess.widgets.InfoBar import InfoBarMessage [as 别名]
# 或者: from pychess.widgets.InfoBar.InfoBarMessage import add_button [as 别名]
 def offerWithdrawn (self, offer):
     log.debug("Human.offerWithdrawn: self=%s %s" % (self, offer))
     assert offer.type in ACTION_NAMES
     heading = _("%s was withdrawn by your opponent") % ACTION_NAMES[offer.type]
     text = _("Your opponent seems to have changed their mind.")
     content = InfoBar.get_message_content(heading, text, Gtk.STOCK_DIALOG_INFO)
     def response_cb (infobar, response, message):
         message.dismiss()
     message = InfoBarMessage(Gtk.MessageType.INFO, content, response_cb)
     message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE, Gtk.ResponseType.CANCEL))
     self.gmwidg.showMessage(message)
开发者ID:sally0813,项目名称:pychess,代码行数:13,代码来源:Human.py

示例5: nonoWhileExamine

# 需要导入模块: from pychess.widgets.InfoBar import InfoBarMessage [as 别名]
# 或者: from pychess.widgets.InfoBar.InfoBarMessage import add_button [as 别名]
    def nonoWhileExamine(self, bm):
        label = Gtk.Label(_("You can't touch this! You are examining a game."))

        def response_cb(infobar, response, message):
            message.dismiss()
            return False

        message = InfoBarMessage(Gtk.MessageType.INFO, label, response_cb)
        message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE,
                                                Gtk.ResponseType.CANCEL))
        self.messages.append(message)
        self.infobar.push_message(message)
开发者ID:leogregianin,项目名称:pychess,代码行数:14,代码来源:__init__.py

示例6: our_seeks_removed

# 需要导入模块: from pychess.widgets.InfoBar import InfoBarMessage [as 别名]
# 或者: from pychess.widgets.InfoBar.InfoBarMessage import add_button [as 别名]
    def our_seeks_removed(self, glm):
        label = Gtk.Label(label=_("Your seeks have been removed"))

        def response_cb(infobar, response, message):
            message.dismiss()
            return False

        message = InfoBarMessage(Gtk.MessageType.INFO, label, response_cb)
        message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE,
                                                Gtk.ResponseType.CANCEL))
        self.messages.append(message)
        self.infobar.push_message(message)
开发者ID:leogregianin,项目名称:pychess,代码行数:14,代码来源:__init__.py

示例7: player_lagged

# 需要导入模块: from pychess.widgets.InfoBar import InfoBarMessage [as 别名]
# 或者: from pychess.widgets.InfoBar.InfoBarMessage import add_button [as 别名]
 def player_lagged (self, bm, player):
     if player in self.gamemodel.ficsplayers:
         content = get_infobarmessage_content(player,
                                              _(" has lagged for 30 seconds"),
                                              self.gamemodel.ficsgame.game_type)
         def response_cb (infobar, response, message):
             message.dismiss()
             return False
         message = InfoBarMessage(Gtk.MessageType.INFO, content, response_cb)
         message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE,
                                                 Gtk.ResponseType.CANCEL))
         self.showMessage(message)
     return False
开发者ID:sally0813,项目名称:pychess,代码行数:15,代码来源:gamewidget.py

示例8: player_on_noplay

# 需要导入模块: from pychess.widgets.InfoBar import InfoBarMessage [as 别名]
# 或者: from pychess.widgets.InfoBar.InfoBarMessage import add_button [as 别名]
    def player_on_noplay(self, bm, player):
        text = _(" noplay listing you")
        content = get_infobarmessage_content(player, text)

        def response_cb(infobar, response, message):
            message.dismiss()
            return False

        message = InfoBarMessage(Gtk.MessageType.INFO, content, response_cb)
        message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE,
                                                Gtk.ResponseType.CANCEL))
        self.messages.append(message)
        self.infobar.push_message(message)
开发者ID:leogregianin,项目名称:pychess,代码行数:15,代码来源:__init__.py

示例9: matchDeclined

# 需要导入模块: from pychess.widgets.InfoBar import InfoBarMessage [as 别名]
# 或者: from pychess.widgets.InfoBar.InfoBarMessage import add_button [as 别名]
    def matchDeclined(self, bm, player):
        text = _(" has declined your offer for a match")
        content = get_infobarmessage_content(player, text)

        def response_cb(infobar, response, message):
            message.dismiss()
            return False

        message = InfoBarMessage(Gtk.MessageType.INFO, content, response_cb)
        message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE,
                                                Gtk.ResponseType.CANCEL))
        self.messages.append(message)
        self.infobar.push_message(message)
开发者ID:leogregianin,项目名称:pychess,代码行数:15,代码来源:__init__.py

示例10: req_not_fit_formula

# 需要导入模块: from pychess.widgets.InfoBar import InfoBarMessage [as 别名]
# 或者: from pychess.widgets.InfoBar.InfoBarMessage import add_button [as 别名]
    def req_not_fit_formula(self, bm, player, formula):
        content = get_infobarmessage_content2(
            player, _(" uses a formula not fitting your match request:"),
            formula)

        def response_cb(infobar, response, message):
            message.dismiss()
            return False

        message = InfoBarMessage(Gtk.MessageType.INFO, content, response_cb)
        message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE,
                                                Gtk.ResponseType.CANCEL))
        self.messages.append(message)
        self.infobar.push_message(message)
开发者ID:leogregianin,项目名称:pychess,代码行数:16,代码来源:__init__.py

示例11: offerDeclined

# 需要导入模块: from pychess.widgets.InfoBar import InfoBarMessage [as 别名]
# 或者: from pychess.widgets.InfoBar.InfoBarMessage import add_button [as 别名]
 def offerDeclined (self, offer):
     log.debug("Human.offerDeclined: self=%s %s" % (self, offer))
     assert offer.type in ACTION_NAMES
     heading = _("%s was declined by your opponent") % ACTION_NAMES[offer.type]
     text = _("Resend %s?" % ACTION_NAMES[offer.type].lower())
     content = InfoBar.get_message_content(heading, text, Gtk.STOCK_DIALOG_INFO)
     def response_cb (infobar, response, message):
         if response == Gtk.ResponseType.ACCEPT:
             self.emit("offer", offer)
         message.dismiss()
     message = InfoBarMessage(Gtk.MessageType.INFO, content, response_cb)
     message.add_button(InfoBarMessageButton(_("Resend"), Gtk.ResponseType.ACCEPT))
     message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE, Gtk.ResponseType.CANCEL))
     self.gmwidg.showMessage(message)
开发者ID:sally0813,项目名称:pychess,代码行数:16,代码来源:Human.py

示例12: opp_not_out_of_time

# 需要导入模块: from pychess.widgets.InfoBar import InfoBarMessage [as 别名]
# 或者: from pychess.widgets.InfoBar.InfoBarMessage import add_button [as 别名]
 def opp_not_out_of_time (self, bm):
     if self.gamemodel.remote_player.time <= 0:
         content = get_infobarmessage_content2(
             self.gamemodel.remote_ficsplayer,
             _(" is lagging heavily but hasn't disconnected"),
             _("Continue to wait for opponent, or try to adjourn the game?"),
             gametype=self.gamemodel.ficsgame.game_type)
         def response_cb (infobar, response, message):
             if response == 2:
                 self.gamemodel.connection.client.run_command("adjourn")
             message.dismiss()
             return False
         message = InfoBarMessage(Gtk.MessageType.QUESTION, content, response_cb)
         message.add_button(InfoBarMessageButton(_("Wait"), Gtk.ResponseType.CANCEL))
         message.add_button(InfoBarMessageButton(_("Adjourn"), 2))
         self.showMessage(message)
     return False
开发者ID:sally0813,项目名称:pychess,代码行数:19,代码来源:gamewidget.py

示例13: on_seek_updated

# 需要导入模块: from pychess.widgets.InfoBar import InfoBarMessage [as 别名]
# 或者: from pychess.widgets.InfoBar.InfoBarMessage import add_button [as 别名]
    def on_seek_updated(self, glm, message_text):
        if "manual accept" in message_text:
            message_text.replace("to manual accept", _("to manual accept"))
        elif "automatic accept" in message_text:
            message_text.replace("to automatic accept",
                                 _("to automatic accept"))
        if "rating range now" in message_text:
            message_text.replace("rating range now", _("rating range now"))
        label = Gtk.Label(label=_("Seek updated") + ": " + message_text)

        def response_cb(infobar, response, message):
            message.dismiss()
            return False

        message = InfoBarMessage(Gtk.MessageType.INFO, label, response_cb)
        message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE,
                                                Gtk.ResponseType.CANCEL))
        self.messages.append(message)
        self.infobar.push_message(message)
开发者ID:leogregianin,项目名称:pychess,代码行数:21,代码来源:__init__.py

示例14: tooManySeeks

# 需要导入模块: from pychess.widgets.InfoBar import InfoBarMessage [as 别名]
# 或者: from pychess.widgets.InfoBar.InfoBarMessage import add_button [as 别名]
    def tooManySeeks(self, bm):
        label = Gtk.Label(label=_(
            "You may only have 3 outstanding seeks at the same time. If you want \
            to add a new seek you must clear your currently active seeks. Clear your seeks?"))
        label.set_width_chars(80)
        label.props.xalign = 0
        label.set_line_wrap(True)

        def response_cb(infobar, response, message):
            if response == Gtk.ResponseType.YES:
                self.connection.client.run_command("unseek")
            message.dismiss()
            return False

        message = InfoBarMessage(Gtk.MessageType.QUESTION, label, response_cb)
        message.add_button(InfoBarMessageButton(Gtk.STOCK_YES,
                                                Gtk.ResponseType.YES))
        message.add_button(InfoBarMessageButton(Gtk.STOCK_NO,
                                                Gtk.ResponseType.NO))
        self.messages.append(message)
        self.infobar.push_message(message)
开发者ID:leogregianin,项目名称:pychess,代码行数:23,代码来源:__init__.py

示例15: offer

# 需要导入模块: from pychess.widgets.InfoBar import InfoBarMessage [as 别名]
# 或者: from pychess.widgets.InfoBar.InfoBarMessage import add_button [as 别名]
    def offer(self, offer):
        log.debug("Human.offer: self=%s %s" % (self, offer))
        assert offer.type in OFFER_MESSAGES

        if self.gamemodel.players[1 - self.color].__type__ is LOCAL:
            self.emit("accept", offer)
            return

        heading, text, takes_param = OFFER_MESSAGES[offer.type]
        if takes_param:
            param = offer.param
            if offer.type == TAKEBACK_OFFER and \
                    self.gamemodel.players[1 - self.color].__type__ != REMOTE:
                param = self.gamemodel.ply - offer.param
            heading = heading % param
            text = text % param

        def response_cb(infobar, response, message):
            if response == Gtk.ResponseType.ACCEPT:
                self.emit("accept", offer)
            elif response == Gtk.ResponseType.NO:
                self.emit("decline", offer)
            message.dismiss()

        content = InfoBar.get_message_content(heading, text,
                                              Gtk.STOCK_DIALOG_QUESTION)
        message = InfoBarMessage(Gtk.MessageType.QUESTION, content,
                                 response_cb)
        message.add_button(InfoBarMessageButton(
            _("Accept"), Gtk.ResponseType.ACCEPT))
        message.add_button(InfoBarMessageButton(
            _("Decline"), Gtk.ResponseType.NO))
        message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE,
                                                Gtk.ResponseType.CANCEL))
        self.gmwidg.showMessage(message)
开发者ID:TPNguyen,项目名称:pychess,代码行数:37,代码来源:Human.py


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