本文整理汇总了Python中sugar3.graphics.alert.Alert.show方法的典型用法代码示例。如果您正苦于以下问题:Python Alert.show方法的具体用法?Python Alert.show怎么用?Python Alert.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sugar3.graphics.alert.Alert
的用法示例。
在下文中一共展示了Alert.show方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __accept_clicked_cb
# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import show [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()
示例2: _object_chooser
# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import show [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']
示例3: _value_changed
# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import show [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()
示例4: can_close
# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import show [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
示例5: __accept_clicked_cb
# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import show [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()
示例6: __accept_clicked_cb
# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import show [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()
示例7: _show_journal_alert
# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import show [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()
示例8: _new_game_alert
# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import show [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()
示例9: _search_clicked_cb
# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import show [as 别名]
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()
示例10: __erase_activate_cb
# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import show [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()
示例11: _erase_button_clicked_cb
# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import show [as 别名]
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()
示例12: _save_epub
# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import show [as 别名]
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()
示例13: _show_journal_alert
# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import show [as 别名]
def _show_journal_alert(self, title, msg, object_id):
open_alert = Alert()
open_alert.props.title = title
open_alert.props.msg = msg
open_icon = Icon(icon_name='zoom-activity')
open_alert.add_button(Gtk.ResponseType.APPLY,
_('Show in Journal'), open_icon)
open_icon.show()
ok_icon = Icon(icon_name='dialog-ok')
open_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(open_alert)
open_alert.connect('response', self.__open_response_cb, object_id)
open_alert.show()
示例14: _erase_comment_cb
# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import show [as 别名]
def _erase_comment_cb(self, widget, event):
alert = Alert()
entry = self.get_selection().get_selected()[1]
erase_string = _('Erase')
alert.props.title = erase_string
alert.props.msg = _('Do you want to permanently erase \"%s\"?') \
% self._store[entry][self.COMMENT_MESSAGE]
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, entry)
journalwindow.get_journal_window().add_alert(alert)
alert.show()
示例15: __create_restart_alert_cb
# 需要导入模块: from sugar3.graphics.alert import Alert [as 别名]
# 或者: from sugar3.graphics.alert.Alert import show [as 别名]
def __create_restart_alert_cb(self, widget=None, event=None):
alert = Alert()
alert.props.title = _("Warning")
alert.props.msg = self._section_view.restart_msg
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()