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


Python alert.NotifyAlert类代码示例

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


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

示例1: _SharedJournalEntry

class _SharedJournalEntry(SharedJournalEntry):
    __gsignals__ = {
        'transfer-state-changed': (GObject.SignalFlags.RUN_FIRST, None,
                                   ([str, str])),
    }

    def __init__(self, account):
        self._account = account
        self._alert = None

    def get_share_menu(self, get_uid_list):
        menu = _ShareMenu(self._account, get_uid_list, True)
        self._connect_transfer_signals(menu)
        return menu

    def __display_alert_cb(self, widget, title, message):
        if self._alert is None:
            self._alert = NotifyAlert()
            self._alert.connect('response', self.__alert_response_cb)
            journalwindow.get_journal_window().add_alert(self._alert)
            self._alert.show()

        self._alert.props.title = title
        self._alert.props.msg = message

    def __alert_response_cb(self, alert, response_id):
        journalwindow.get_journal_window().remove_alert(alert)
        self._alert = None

    def _connect_transfer_signals(self, transfer_widget):
        transfer_widget.connect('transfer-state-changed',
                                self.__display_alert_cb)
开发者ID:i5o,项目名称:dropbox-webservice,代码行数:32,代码来源:account.py

示例2: action

        def action(alert, response):
            self.remove_alert(alert)
            if not response is Gtk.ResponseType.OK:
                return

            try:
                f = open(file_path, 'r')
                # Test if the file is valid project.
                json.loads(f.read())
                f.close()

                self.read_file(file_path)
                self.game.run(True)
            except:
                title = _('Load project from journal')
                if not journal:
                    title = _('Load example')
                msg = _(
                    'Error: Cannot open Physics project from this file.')
                alert = NotifyAlert(5)
                alert.props.title = title
                alert.props.msg = msg
                alert.connect(
                    'response',
                    lambda alert,
                    response: self.remove_alert(alert))
                self.add_alert(alert)
开发者ID:godiard,项目名称:physics,代码行数:27,代码来源:activity.py

示例3: _load_project

    def _load_project(self, button):
        chooser = ObjectChooser(parent=self)
        result = chooser.run()
        if result == Gtk.ResponseType.ACCEPT:
            dsobject = chooser.get_selected_object()
            file_path = dsobject.get_file_path()
            try:
                f = open(file_path, 'r')
                # Test if the file is valid project.
                json.loads(f.read())
                f.close()

                self.read_file(file_path)
                self.game.run(True)
            except:
                title = _('Load project from journal')
                msg = _(
                    'Error: Cannot open Physics project from this file.')
                alert = NotifyAlert(5)
                alert.props.title = title
                alert.props.msg = msg
                alert.connect(
                    'response',
                    lambda alert,
                    response: self.remove_alert(alert))
                self.add_alert(alert)

            chooser.destroy()
开发者ID:i5o,项目名称:physics,代码行数:28,代码来源:activity.py

示例4: _alert

 def _alert(self, title, text=None):
     alert = NotifyAlert(timeout=20)
     alert.props.title = title
     alert.props.msg = text
     self.add_alert(alert)
     alert.connect('response', self._alert_cancel_cb)
     alert.show()
开发者ID:leonardcj,项目名称:getiabooks,代码行数:7,代码来源:GetIABooksActivity.py

示例5: _create_timed_alert

    def _create_timed_alert(self, title, msg, timeout=10):
        alert = NotifyAlert(timeout)
        alert.props.title = title
        alert.props.msg = msg
        alert.connect('response', self._alert_cancel_cb)

        self.add_alert(alert)
开发者ID:erik,项目名称:translate-activity,代码行数:7,代码来源:TranslateActivity.py

示例6: add_view

    def add_view(self, widget):
        if len(self._view_icons) >= 5:
            for x in self.activity._alerts:
                self.activity.remove_alert(x)
            alert = NotifyAlert(10)
            alert.props.title = _('Limit reached')
            alert.props.msg = _('You have reached the maximum limit of '
                                'favorites views, please delete some before '
                                'continuing.')
            self.activity.add_alert(alert)
            alert.connect('response',
                          lambda x, y: self.activity.remove_alert(x))
            return

        current = len(self._view_buttons) + 1
        label = _('Favorites view %d') % current
        button = ToolbarButton(label=label, icon_name='view-radial')
        page = FavoritePage(button, self, 'view-radial', 'emblem-favorite',
                            label)
        button.set_page(page)

        self._view_icons[button] = 'view-radial'
        self._favorite_icons[button] = 'emblem-favorite'
        self._view_buttons[button] = button
        if self.favorite_names_enabled:
            self._favorite_names[button] = label

        self.insert(button, -1)
        self.save_to_gconf()
        self.show_all()
开发者ID:svineet,项目名称:manage-homeviews,代码行数:30,代码来源:homeviews.py

示例7: _alert

 def _alert(self, title, msg=None):
     a = NotifyAlert()
     a.props.title = title
     a.props.msg = msg
     self.activity.add_alert(a)
     a.connect('response', lambda a, r: self.activity.remove_alert(a))
     a.show()
开发者ID:AbrahmAB,项目名称:reflect,代码行数:7,代码来源:textchannelwrapper.py

示例8: alert

 def alert(self, title, text=None, timeout=5):
     if text != None:
         alert = NotifyAlert(timeout=timeout)
         alert.props.title = title
         alert.props.msg = text
         self.add_alert(alert)
         alert.connect('response', self.alert_cancel_cb)
         alert.show()
开发者ID:HFOSS-OVC,项目名称:Open-Video-chat,代码行数:8,代码来源:ovc.py

示例9: FacebookAccount

class FacebookAccount(account.Account):

    ACCESS_TOKEN_KEY = "/desktop/sugar/collaboration/facebook_access_token"
    ACCESS_TOKEN_KEY_EXPIRATION_DATE = \
        "/desktop/sugar/collaboration/facebook_access_token_expiration_date"

    def __init__(self):
        self._client = GConf.Client.get_default()
        facebook.FbAccount.set_access_token(self._access_token())
        self._alert = None

    def get_description(self):
        return ACCOUNT_NAME

    def is_configured(self):
        return self._access_token() is not None

    def is_active(self):
        expiration_date = \
            self._client.get_int(self.ACCESS_TOKEN_KEY_EXPIRATION_DATE)
        return expiration_date != 0 and expiration_date > time.time()

    def get_share_menu(self, journal_entry_metadata):
        fb_share_menu = _FacebookShareMenu(journal_entry_metadata,
                                          self.is_active())
        self._connect_transfer_signals(fb_share_menu)
        return fb_share_menu

    def get_refresh_menu(self):
        fb_refresh_menu = _FacebookRefreshMenu(self.is_active())
        self._connect_transfer_signals(fb_refresh_menu)
        return fb_refresh_menu

    def _connect_transfer_signals(self, transfer_widget):
        transfer_widget.connect('transfer-state-changed',
                                self._transfer_state_changed_cb)

    def _transfer_state_changed_cb(self, widget, state_message):
        logging.debug('_transfer_state_changed_cb')

        # First, remove any existing alert
        if self._alert is None:
            logging.debug('creating new alert')
            self._alert = NotifyAlert()
            self._alert.props.title = ACCOUNT_NAME
            self._alert.connect('response', self._alert_response_cb)
            journalwindow.get_journal_window().add_alert(self._alert)
            self._alert.show()

        logging.debug(state_message)
        self._alert.props.msg = state_message

    def _alert_response_cb(self, alert, response_id):
        journalwindow.get_journal_window().remove_alert(alert)
        self._alert = None

    def _access_token(self):
        return self._client.get_string(self.ACCESS_TOKEN_KEY)
开发者ID:tchx84,项目名称:social-sugar,代码行数:58,代码来源:account.py

示例10: _alert

 def _alert(self, title, text=None):
     alert = NotifyAlert(timeout=5)
     alert.props.title = title
     alert.props.msg = text
     self.add_alert(alert)
     alert.connect('response', self._alert_cancel_cb)
     alert.show()
     self._has_alert = True
     self._fixed_resize_cb()
开发者ID:sugarlabs,项目名称:chat,代码行数:9,代码来源:activity.py

示例11: notify_alert

    def notify_alert(self):
        alert = NotifyAlert()
        alert.props.title = _('Saving icon...')
        msg = _('A restart is required before your new icon will appear.')
        alert.props.msg = msg

        def remove_alert(alert, response_id):
            self.remove_alert(alert)

        alert.connect('response', remove_alert)
        self.add_alert(alert)
开发者ID:Daksh,项目名称:xo-icon,代码行数:11,代码来源:activity.py

示例12: _delete_log_cb

 def _delete_log_cb(self, widget):
     if self.viewer.active_log:
         logfile = self.viewer.active_log.logfile
         try:
             os.remove(logfile)
         except OSError, err:
             notify = NotifyAlert()
             notify.props.title = _('Error')
             notify.props.msg = _('%(error)s when deleting %(file)s') % \
                 {'error': err.strerror, 'file': logfile}
             notify.connect('response', _notify_response_cb, self)
             self.add_alert(notify)
开发者ID:sugarlabs,项目名称:log-activity,代码行数:12,代码来源:logviewer.py

示例13: _notify_new_game

    def _notify_new_game(self, prompt):
        ''' Called from New Game button since loading a new game can
        be slooow!! '''
        alert = NotifyAlert(3)
        alert.props.title = prompt
        alert.props.msg = _('A new game is loading.')

        def _notification_alert_response_cb(alert, response_id, self):
            self.remove_alert(alert)

        alert.connect('response', _notification_alert_response_cb, self)
        self.add_alert(alert)
        alert.show()
开发者ID:sugarlabs,项目名称:dimensions,代码行数:13,代码来源:Dimensions.py

示例14: _confirm_save

    def _confirm_save(self):
        ''' Called from confirmation alert '''
        
        client.set_string('/desktop/sugar/user/color', '%s,%s' % (
                self._game.colors[0], self._game.colors[1]))
        alert = NotifyAlert()
        alert.props.title = _('Saving colors')
        alert.props.msg = _('A restart is required before your new colors '
                            'will appear.')

	def _notification_alert_response_cb(alert, response_id, self):
		self.remove_alert(alert)
        alert.connect('response', _notification_alert_response_cb, self)
        self.add_alert(alert)
        alert.show()
开发者ID:leonardcj,项目名称:xocolors,代码行数:15,代码来源:XOEditorActivity.py

示例15: __display_alert_cb

 def __display_alert_cb(self, widget, message):
     if self._alert is None:
         self._alert = NotifyAlert()
         self._alert.props.title = ACCOUNT_NAME
         self._alert.connect('response', self.__alert_response_cb)
         journalwindow.get_journal_window().add_alert(self._alert)
         self._alert.show()
     self._alert.props.msg = message
开发者ID:cristian99garcia,项目名称:teachershare,代码行数:8,代码来源:account.py


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