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


Python Alert.connect方法代码示例

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


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

示例1: _incompatible

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import connect [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

示例2: _value_changed

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import connect [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

示例3: _show_journal_alert

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import connect [as 别名]
    def _show_journal_alert(self, title, msg):
        _stop_alert = Alert()
        _stop_alert.props.title = title
        _stop_alert.props.msg = msg

        if _HAS_BUNDLE_LAUNCHER:
                bundle = get_bundle(object_id=self._object_id)

        if bundle is not None:
            icon = Icon(file=bundle.get_icon())
            label = _('Open with %s') % bundle.get_name()
            _stop_alert.add_button(Gtk.ResponseType.ACCEPT, label, icon)
        else:
            icon = Icon(icon_name='zoom-activity')
            label = _('Show in Journal')
            _stop_alert.add_button(Gtk.ResponseType.APPLY, label, icon)
        icon.show()

        ok_icon = Icon(icon_name='dialog-ok')
        _stop_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(_stop_alert)
        _stop_alert.connect('response', self.__stop_response_cb)
        _stop_alert.show()
开发者ID:leonardcj,项目名称:get-books-activity,代码行数:30,代码来源:GetIABooksActivity.py

示例4: __accept_clicked_cb

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import connect [as 别名]
    def __accept_clicked_cb(self, widget):
        if self._section_view.needs_restart:
            self._section_toolbar.accept_button.set_sensitive(False)
            self._section_toolbar.cancel_button.set_sensitive(False)
            alert = Alert()
            alert.props.title = _('Warning')
            alert.props.msg = _('Changes require restart')

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

            if self._current_option != 'aboutme':
                icon = Icon(icon_name='dialog-ok')
                alert.add_button(Gtk.ResponseType.ACCEPT, _('Later'), icon)
                icon.show()

            icon = Icon(icon_name='system-restart')
            alert.add_button(Gtk.ResponseType.APPLY, _('Restart now'), icon)
            icon.show()

            self._vbox.pack_start(alert, False, False, 0)
            self._vbox.reorder_child(alert, 2)
            alert.connect('response', self.__response_cb)
            alert.show()
        else:
            self._show_main_view()
开发者ID:ChristoferR,项目名称:sugar,代码行数:30,代码来源:gui.py

示例5: __create_empty_file_cb

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import connect [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

示例6: __accept_clicked_cb

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import connect [as 别名]
    def __accept_clicked_cb(self, widget):
        if hasattr(self._section_view, "apply"):
            self._section_view.apply()

        if self._section_view.needs_restart:
            self._section_toolbar.accept_button.set_sensitive(False)
            self._section_toolbar.cancel_button.set_sensitive(False)
            alert = Alert()
            alert.props.title = _("Warning")
            alert.props.msg = _("Changes require restart")

            if self._section_view.props.is_cancellable:
                icon = Icon(icon_name="dialog-cancel")
                alert.add_button(Gtk.ResponseType.CANCEL, _("Cancel changes"), icon)
                icon.show()

            if self._current_option not in ("aboutme", "backup"):
                icon = Icon(icon_name="dialog-ok")
                alert.add_button(Gtk.ResponseType.ACCEPT, _("Later"), icon)
                icon.show()

            icon = Icon(icon_name="system-restart")
            alert.add_button(Gtk.ResponseType.APPLY, _("Restart now"), icon)
            icon.show()

            self._vbox.pack_start(alert, False, False, 0)
            self._vbox.reorder_child(alert, 2)
            alert.connect("response", self.__response_cb)
            alert.show()
        else:
            self._show_main_view()
开发者ID:richaseh,项目名称:sugar,代码行数:33,代码来源:gui.py

示例7: __accept_clicked_cb

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import connect [as 别名]
    def __accept_clicked_cb(self, widget):
        if hasattr(self._section_view, "apply"):
            self._section_view.apply()

        if self._section_view.needs_restart:
            self._section_toolbar.accept_button.set_sensitive(False)
            self._section_toolbar.cancel_button.set_sensitive(False)
            alert = Alert()
            alert.props.title = _('Warning')
            alert.props.msg = _('Changes require restart')

            if self._section_view.props.is_cancellable:
                icon = Icon(icon_name='dialog-cancel')
                alert.add_button(Gtk.ResponseType.CANCEL,
                                 _('Cancel changes'), icon)
                icon.show()

            if self._section_view.props.is_deferrable:
                icon = Icon(icon_name='dialog-ok')
                alert.add_button(Gtk.ResponseType.ACCEPT, _('Later'), icon)
                icon.show()

            icon = Icon(icon_name='system-restart')
            alert.add_button(Gtk.ResponseType.APPLY, _('Restart now'), icon)
            icon.show()

            self.add_alert(alert)
            alert.connect('response', self.__response_cb)
            alert.show()
        else:
            self._show_main_view()
开发者ID:AbrahmAB,项目名称:sugar-prototype,代码行数:33,代码来源:gui.py

示例8: can_close

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import connect [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

示例9: _object_chooser

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import connect [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

示例10: _show_alert

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import connect [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

示例11: _create_alert

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import connect [as 别名]
    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,代码行数:13,代码来源:TranslateActivity.py

示例12: __crashed_cb

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import connect [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

示例13: _new_game_alert

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import connect [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

示例14: __activate_game_cb

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import connect [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

示例15: __activate_art4apps_game_cb

# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import connect [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


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