• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python alert.Alert类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: _show_journal_alert

    def _show_journal_alert(self, title, msg):
        _stop_alert = Alert()
        _stop_alert.props.title = title
        _stop_alert.props.msg = msg
        _stop_alert.add_button(Gtk.ResponseType.APPLY,
                               _('Show in Journal'),
                               Icon(icon_name='zoom-activity'))
        _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:quozl,项目名称:fototoon-activity,代码行数:16,代码来源:historietaactivity.py


示例17: _alert

    def _alert(self, title, text=None):
        try:
            self.remove_alert(self.alert)

        finally:
            self.alert = Alert()
            self.alert.props.title = title
            self.alert.props.msg = text
            self.add_alert(self.alert)
            self.alert.connect('response', self._alert_cancel_cb)
            self.alert.show()
开发者ID:sugarlabs,项目名称:devtutor-activity,代码行数:11,代码来源:activity.py


示例18: _save_epub

    def _save_epub(self):
        epub_file_name = create_ebub_from_book_model(
            self.metadata['title'], self._book_model)

        # create a new journal item
        fileObject = datastore.create()
        fileObject.metadata['title'] = \
            _('"%s" as book') % self.metadata['title']
        fileObject.metadata['mime_type'] = 'application/epub+zip'

        full_text = ''
        for page in self._book_model.get_pages():
            full_text += page.text + '\n'
        fileObject.metadata['fulltext'] = full_text
        fileObject.metadata['icon-color'] = self.metadata['icon-color']
        fileObject.metadata['keep'] = self.metadata.get('keep', '0')

        fileObject.metadata['preview'] = self.metadata['preview']
        fileObject.file_path = epub_file_name

        # store the journal item
        datastore.write(fileObject, transfer_ownership=True)
        book_object_id = fileObject.object_id

        fileObject.destroy()
        del fileObject
        shutil.rmtree(os.path.dirname(epub_file_name))

        finish_alert = Alert()
        finish_alert.props.title = _('Book created')
        finish_alert.props.msg = _('You can read the book in your Journal')
        open_icon = Icon(icon_name='zoom-activity')
        finish_alert.add_button(Gtk.ResponseType.APPLY,
                                _('Show in Journal'), open_icon)
        open_icon.show()
        ok_icon = Icon(icon_name='dialog-ok')
        finish_alert.add_button(Gtk.ResponseType.OK, _('Ok'), ok_icon)
        ok_icon.show()
        # Remove other alerts
        for alert in self._alerts:
            self.remove_alert(alert)

        self.add_alert(finish_alert)
        finish_alert.connect('response', self.__book_saved_alert_response_cb,
                             book_object_id)
        finish_alert.show()
开发者ID:leonardcj,项目名称:write-books-activity,代码行数:46,代码来源:activity.py


示例19: _shared_cb

    def _shared_cb(self, activity):        
        self._logger.debug('My activity was shared')
        self.alert = Alert()
        self.alert.props.title = 'Shared Activity'
        self.alert.props.msg = 'Shared messages to be displayed here'
        self.add_alert(self.alert)
        self.initiating = True
        self._sharing_setup()

        self._logger.debug('This is my activity: making a tube...')
        id = self.tubes_chan[telepathy.CHANNEL_TYPE_TUBES].OfferDBusTube(
            SERVICE, {})
开发者ID:sugarlabs,项目名称:devtutor-activity,代码行数:12,代码来源:activity.py


示例20: _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, GStreamer is too old.'))
        self.set_canvas(label)

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

        self.show_all()
开发者ID:sugarlabs,项目名称:Measure,代码行数:21,代码来源:measure.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python alert.NotifyAlert类代码示例发布时间:2022-05-27
下一篇:
Python env.get_user_activities_path函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap