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


Python alert.Alert类代码示例

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


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

示例1: _incompatible

    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,代码行数:32,代码来源:webactivity.py

示例2: __init__

    def __init__(self, timeout=5, **kwargs):
        Alert.__init__(self, **kwargs)

        self._pb = Gtk.ProgressBar()
        self._msg_box.pack_start(self._pb, False, False, 0)
        self._pb.set_size_request(int(Gdk.Screen.width() * 9. / 10.), -1)
        self._pb.set_fraction(0.0)
        self._pb.show()
开发者ID:leonardcj,项目名称:imageviewer-activity,代码行数:8,代码来源:ImageViewerActivity.py

示例3: _show_alert

 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,代码行数:9,代码来源:develop_app.py

示例4: __init__

    def __init__(self, **kwargs):
        Alert.__init__(self, **kwargs)

        icon = Icon(icon_name='dialog-cancel')
        self.add_button(Gtk.ResponseType.CANCEL, _('Save As'), icon)
        icon.show()

        icon = Icon(icon_name='dialog-ok')
        self.add_button(Gtk.ResponseType.OK, _('Overwrite'), icon)
        icon.show()
开发者ID:iamutkarshtiwari,项目名称:Browse-fiddleFeature,代码行数:10,代码来源:webconsole.py

示例5: can_close

 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,代码行数:27,代码来源:webactivity.py

示例6: _create_alert

    def _create_alert(self, title, msg):
        """Create and display an alert that cannot be dismissed by the user."""

        alert = Alert()
        alert.props.title = title
        alert.props.msg = msg
        alert.connect('response', self._alert_cancel_cb)

        self.add_alert(alert)

        return alert
开发者ID:erik,项目名称:translate-activity,代码行数:11,代码来源:TranslateActivity.py

示例7: _search_clicked_cb

    def _search_clicked_cb(self, widget):
        title = self.searchentry.get_text()
        wiki = self.wikimenu.combo.props.value

        if not title:
            return

        if book.wiki.find('%s (from %s)' % (title, wiki))[0]:
            alert = Alert()
            alert.props.title = _('Exists')
            alert.props.msg = _('"%s" article already exists' % title)
            alert.show()
        else:
            Timer(0, self._download, [title, wiki]).start()
开发者ID:iamutkarshtiwari,项目名称:infoslicer,代码行数:14,代码来源:library.py

示例8: _new_game_alert

 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,代码行数:13,代码来源:game.py

示例9: _show_error_alert

 def _show_error_alert(self, title, msg=None):
     self._alert = ErrorAlert()
     self._alert.props.title = title
     if msg is not None:
         self._alert.props.msg = msg
     self.add_alert(self._alert)
     self._alert.connect('response', self._alert_cancel_cb)
     self._alert.show()
开发者ID:cristian99garcia,项目名称:jukebox-activity,代码行数:8,代码来源:activity.py

示例10: __register_activate_cb

    def __register_activate_cb(self, icon):
        alert = Alert()
        try:
            schoolserver.register_laptop()
        except RegisterError as e:
            alert.props.title = _('Registration Failed')
            alert.props.msg = '%s' % e
        else:
            alert.props.title = _('Registration Successful')
            alert.props.msg = _('You are now registered '
                                'with your school server.')

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

        self._box.add_alert(alert)
        alert.connect('response', self.__register_alert_response_cb)
开发者ID:curiousguy13,项目名称:sugar,代码行数:17,代码来源:favoritesview.py

示例11: __erase_activate_cb

 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,代码行数:14,代码来源:palettes.py

示例12: _object_chooser

    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,代码行数:31,代码来源:activity.py

示例13: _value_changed

    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,代码行数:32,代码来源:activity.py

示例14: _erase_button_clicked_cb

 def _erase_button_clicked_cb(self, button):
     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:hgarrereyn,项目名称:sugar,代码行数:15,代码来源:journaltoolbox.py

示例15: __pdf_alert

    def __pdf_alert(self, object_id):
        alert = Alert()
        alert.props.title = _("Page saved")
        alert.props.msg = _("The page has been saved as PDF to journal")

        alert.add_button(Gtk.ResponseType.APPLY, _("Show in Journal"), Icon(icon_name="zoom-activity"))
        alert.add_button(Gtk.ResponseType.OK, _("Ok"), Icon(icon_name="dialog-ok"))

        # Remove other alerts
        for alert in self._activity._alerts:
            self._activity.remove_alert(alert)

        self._activity.add_alert(alert)
        alert.connect("response", self.__pdf_response_alert, object_id)
        alert.show_all()
开发者ID:richaseh,项目名称:browse,代码行数:15,代码来源:webtoolbar.py


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