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


Python Alert.add_button方法代码示例

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


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

示例1: __create_empty_file_cb

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import add_button [as 别名]
    def __create_empty_file_cb(self, button):
        alert = Alert()
        alert.props.title = _('Create new file')
        alert.props.msg = _('Select the name of the file')

        # HACK
        alert._hbox.remove(alert._buttons_box)
        alert.entry = Gtk.Entry()
        alert._hbox.pack_start(alert.entry, True, True, 0)

        alert._buttons_box = Gtk.HButtonBox()
        alert._buttons_box.set_layout(Gtk.ButtonBoxStyle.END)
        alert._buttons_box.set_spacing(style.DEFAULT_SPACING)
        alert._hbox.pack_start(alert._buttons_box, True, True, 0)

        icon = Icon(icon_name='dialog-cancel')
        alert.add_button(Gtk.ResponseType.CANCEL, _('Cancel'), icon)

        icon = Icon(icon_name='dialog-ok')
        alert.add_button(Gtk.ResponseType.OK, _('Ok'), icon)
        alert.show_all()
        #

        self.add_alert(alert)
        alert.connect('response', self.__create_file_alert_cb)
开发者ID:svineet,项目名称:develop-activity,代码行数:27,代码来源:develop_app.py

示例2: can_close

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import add_button [as 别名]
 def can_close(self):
     if self._force_close:
         return True
     elif downloadmanager.can_quit():
         return True
     else:
         alert = Alert()
         alert.props.title = ngettext('Download in progress',
                                      'Downloads in progress',
                                      downloadmanager.num_downloads())
         message = ngettext('Stopping now will erase your download',
                            'Stopping now will erase your downloads',
                            downloadmanager.num_downloads())
         alert.props.msg = message
         cancel_icon = Icon(icon_name='dialog-cancel')
         cancel_label = ngettext('Continue download', 'Continue downloads',
                                 downloadmanager.num_downloads())
         alert.add_button(Gtk.ResponseType.CANCEL, cancel_label,
                          cancel_icon)
         stop_icon = Icon(icon_name='dialog-ok')
         alert.add_button(Gtk.ResponseType.OK, _('Stop'), stop_icon)
         stop_icon.show()
         self.add_alert(alert)
         alert.connect('response', self.__inprogress_response_cb)
         alert.show()
         self.present()
         return False
开发者ID:City-busz,项目名称:browse-activity,代码行数:29,代码来源:webactivity.py

示例3: _incompatible

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import add_button [as 别名]
    def _incompatible(self):
        ''' Display abbreviated activity user interface with alert '''
        toolbox = ToolbarBox()
        stop = StopButton(self)
        toolbox.toolbar.add(stop)
        self.set_toolbar_box(toolbox)

        title = _('Activity not compatible with this system.')
        msg = _('Please downgrade activity and try again.')
        alert = Alert(title=title, msg=msg)
        alert.add_button(0, 'Stop', Icon(icon_name='activity-stop'))
        self.add_alert(alert)

        label = Gtk.Label(_('Uh oh, WebKit2 is too old. '
                            'Browse-200 and later require WebKit2 API 4.0, '
                            'sorry!'))
        self.set_canvas(label)

        '''
        Workaround: start Terminal activity, then type

        sugar-erase-bundle org.laptop.WebActivity

        then in My Settings, choose Software Update, which will offer
        older Browse.
        '''

        alert.connect('response', self.__incompatible_response_cb)
        stop.connect('clicked', self.__incompatible_stop_clicked_cb,
                         alert)

        self.show_all()
开发者ID:sugarlabs,项目名称:browse-activity,代码行数:34,代码来源:webactivity.py

示例4: _value_changed

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import add_button [as 别名]
    def _value_changed(self, cell, path, new_text, model, activity):
        _logger.info("Change '%s' to '%s'" % (model[path][1], new_text))
        is_number = True
        number = new_text.replace(",", ".")
        try:
            float(number)
        except ValueError:
            is_number = False

        if is_number:
            decimals = utils.get_decimals(str(float(number)))
            new_text = locale.format('%.' + decimals + 'f', float(number))
            model[path][1] = str(new_text)

            self.emit("value-changed", str(path), number)

        elif not is_number:
            alert = Alert()

            alert.props.title = _('Invalid Value')
            alert.props.msg = \
                           _('The value must be a number (integer or decimal)')

            ok_icon = Icon(icon_name='dialog-ok')
            alert.add_button(Gtk.ResponseType.OK, _('Ok'), ok_icon)
            ok_icon.show()

            alert.connect('response', lambda a, r: activity.remove_alert(a))

            activity.add_alert(alert)

            alert.show()
开发者ID:sugarlabs,项目名称:AnalyzeJournal,代码行数:34,代码来源:activity.py

示例5: _object_chooser

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import add_button [as 别名]
    def _object_chooser(self, mime_type, type_name):
        chooser = ObjectChooser()
        matches_mime_type = False

        response = chooser.run()
        if response == Gtk.ResponseType.ACCEPT:
            jobject = chooser.get_selected_object()
            metadata = jobject.metadata
            file_path = jobject.file_path

            if metadata['mime_type'] == mime_type:
                matches_mime_type = True

            else:
                alert = Alert()

                alert.props.title = _('Invalid object')
                alert.props.msg = \
                       _('The selected object must be a %s file' % (type_name))

                ok_icon = Icon(icon_name='dialog-ok')
                alert.add_button(Gtk.ResponseType.OK, _('Ok'), ok_icon)
                ok_icon.show()

                alert.connect('response', lambda a, r: self.remove_alert(a))

                self.add_alert(alert)

                alert.show()

        return matches_mime_type, file_path, metadata['title']
开发者ID:sugarlabs,项目名称:AnalyzeJournal,代码行数:33,代码来源:activity.py

示例6: _show_alert

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import add_button [as 别名]
 def _show_alert(self, message, title=None):
     alert = Alert()
     if title is None:
         title = _('Atention')
     alert.props.title = title
     alert.props.msg = message
     alert.add_button(Gtk.ResponseType.OK, _('Ok'))
     self.add_alert(alert)
     alert.connect('response', self._alert_response_cb)
开发者ID:svineet,项目名称:develop-activity,代码行数:11,代码来源:develop_app.py

示例7: __crashed_cb

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import add_button [as 别名]
    def __crashed_cb(self, browser):
        self.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.LEFT_PTR))
        uri = browser.cached_uri
        logging.error('WebKit2 WebView at uri %r has crashed', uri)
        self.close_tab(browser.get_parent())

        alert = Alert(title=_('This tab has crashed Browse: %s') % uri,
                      msg=_('If you reopen the tab, it may just crash again'))
        alert.add_button(Gtk.ResponseType.OK, _('Reopen'))
        alert.add_button(Gtk.ResponseType.CANCEL, _('Disregard'))
        alert.connect('response', self.__crashed_alert_cb, uri)
        self._activity.add_alert(alert)
开发者ID:iamutkarshtiwari,项目名称:browse-activity,代码行数:14,代码来源:browser.py

示例8: _new_game_alert

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import add_button [as 别名]
 def _new_game_alert(self):
     alert = Alert()
     alert.props.title = _('New game')
     alert.props.msg = _('Do you want to play a new game?')
     icon = Icon(icon_name='dialog-cancel')
     alert.add_button(Gtk.ResponseType.CANCEL, _('Cancel'), icon)
     icon.show()
     ok_icon = Icon(icon_name='dialog-ok')
     alert.add_button(Gtk.ResponseType.OK, _('New game'), ok_icon)
     ok_icon.show()
     alert.connect('response', self.__game_alert_response_cb)
     self._parent.add_alert(alert)
     alert.show()
开发者ID:sugarlabs,项目名称:cookiesearch,代码行数:15,代码来源:game.py

示例9: __activate_game_cb

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import add_button [as 别名]
 def __activate_game_cb(self, menu, i):
     self._game_selected_index = i
     if self.activity.game.model.is_demo:
         self._change_game()
     else:
         alert = Alert()
         alert.props.title = _('Discard your modified game?')
         icon = Icon(icon_name='dialog-ok')
         alert.add_button(1, _('Discard'), icon)
         icon = Icon(icon_name='dialog-cancel')
         alert.add_button(0, _('Do not discard'), icon)
         alert.connect('response', self._change_game_alert_cb)
         self.activity.add_alert(alert)
开发者ID:godiard,项目名称:memorize-activity,代码行数:15,代码来源:memorizetoolbar.py

示例10: __activate_art4apps_game_cb

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import add_button [as 别名]
 def __activate_art4apps_game_cb(self, menu, category, language):
     self._art4apps_data = (category, language)
     if self.activity.game.model.is_demo:
         self._change_art4apps_game(category, language)
     else:
         alert = Alert()
         alert.props.title = _('Discard your modified game?')
         icon = Icon(icon_name='dialog-ok')
         alert.add_button(1, _('Discard'), icon)
         icon = Icon(icon_name='dialog-cancel')
         alert.add_button(0, _('Do not discard'), icon)
         alert.connect('response', self._change_art4apps_game_alert_cb)
         self.activity.add_alert(alert)
开发者ID:godiard,项目名称:memorize-activity,代码行数:15,代码来源:memorizetoolbar.py

示例11: __save_ebook_clicked_cb

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import add_button [as 别名]
 def __save_ebook_clicked_cb(self, button):
     alert = Alert()
     alert.props.title = _('Book creation')
     alert.props.msg = _('Do you want to add an image for the cover?')
     icon = Icon(icon_name='dialog-ok')
     alert.add_button(Gtk.ResponseType.YES, _('Yes'), icon)
     icon.show()
     icon = Icon(icon_name='dialog-cancel')
     alert.add_button(Gtk.ResponseType.NO, _('No'), icon)
     icon.show()
     alert.connect('response', self.__add_cover_response_cb,
                   self._set_cover_and_create_book)
     self.add_alert(alert)
开发者ID:leonardcj,项目名称:write-books-activity,代码行数:15,代码来源:activity.py

示例12: _clear_game_bt

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import add_button [as 别名]
 def _clear_game_bt(self, button):
     if self.activity.game.model.is_demo or \
             len(self.activity.cardlist.pairs) == 0:
         self.clear_game()
     else:
         alert = Alert()
         alert.props.title = _('Clear all the tiles from the game?')
         icon = Icon(icon_name='dialog-ok')
         alert.add_button(1, _('Clear'), icon)
         icon = Icon(icon_name='dialog-cancel')
         alert.add_button(0, _('Do not clear'), icon)
         alert.connect('response', self._clear_game_alert_cb)
         self.activity.add_alert(alert)
开发者ID:godiard,项目名称:memorize-activity,代码行数:15,代码来源:createtoolbar.py

示例13: _show_alert

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import add_button [as 别名]
    def _show_alert(self, title, msg):
        _stop_alert = Alert()
        _stop_alert.props.title = title
        _stop_alert.props.msg = msg
        _stop_alert.add_button(Gtk.ResponseType.OK, _('Ok'),
                               Icon(icon_name='dialog-ok'))
        # Remove other alerts
        for alert in self._alerts:
            self.remove_alert(alert)

        self.add_alert(_stop_alert)
        _stop_alert.connect('response', self.__stop_response_cb)
        _stop_alert.show_all()
开发者ID:sugarlabs,项目名称:edit-fonts-activity,代码行数:15,代码来源:EditFonts.py

示例14: __erase_activate_cb

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import add_button [as 别名]
 def __erase_activate_cb(self, menu_item):
     alert = Alert()
     erase_string = _("Erase")
     alert.props.title = erase_string
     alert.props.msg = _('Do you want to permanently erase "%s"?') % self._metadata["title"]
     icon = Icon(icon_name="dialog-cancel")
     alert.add_button(Gtk.ResponseType.CANCEL, _("Cancel"), icon)
     icon.show()
     ok_icon = Icon(icon_name="dialog-ok")
     alert.add_button(Gtk.ResponseType.OK, erase_string, ok_icon)
     ok_icon.show()
     alert.connect("response", self.__erase_alert_response_cb)
     journalwindow.get_journal_window().add_alert(alert)
     alert.show()
开发者ID:surajgillespie,项目名称:sugar,代码行数:16,代码来源:palettes.py

示例15: _show_keep_failed_dialog

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import add_button [as 别名]
    def _show_keep_failed_dialog(self):
        alert = Alert()
        alert.props.title = _('Keep error')
        alert.props.msg = _('Keep error: all changes will be lost')

        cancel_icon = Icon(icon_name='dialog-cancel')
        alert.add_button(Gtk.ResponseType.CANCEL, _('Don\'t stop'), cancel_icon)

        stop_icon = Icon(icon_name='dialog-ok')
        alert.add_button(Gtk.ResponseType.OK, _('Stop anyway'), stop_icon)

        self.add_alert(alert)
        alert.connect('response', self._keep_failed_dialog_response_cb)

        self.reveal()
开发者ID:worr,项目名称:sugar-toolkit-gtk3-1,代码行数:17,代码来源:activity.py


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