本文整理汇总了Python中sugar3.graphics.alert.NotifyAlert类的典型用法代码示例。如果您正苦于以下问题:Python NotifyAlert类的具体用法?Python NotifyAlert怎么用?Python NotifyAlert使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NotifyAlert类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: _SharedJournalEntry
class _SharedJournalEntry(account.SharedJournalEntry):
__gsignals__ = {
'transfer-state-changed': (GObject.SignalFlags.RUN_FIRST, None,
([str])),
}
def __init__(self, fbaccount):
self._account = fbaccount
self._alert = None
def get_share_menu(self, journal_entry_metadata):
menu = _ShareMenu(
self._account.facebook,
journal_entry_metadata,
self._account.get_token_state() == self._account.STATE_VALID)
self._connect_transfer_signals(menu)
return menu
def get_refresh_menu(self):
menu = _RefreshMenu(
self._account.facebook,
self._account.get_token_state() == self._account.STATE_VALID)
self._connect_transfer_signals(menu)
return 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:
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
开发者ID:tchx84,项目名称:facebook,代码行数:46,代码来源:account.py
示例17: _on_send_button_clicked_cb
def _on_send_button_clicked_cb(self, button):
window = self._activity.get_window()
old_cursor = window.get_cursor()
window.set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH))
Gdk.flush()
identifier = str(int(time.time()))
filename = '%s.zip' % identifier
filepath = os.path.join(activity.get_activity_root(), filename)
success = True
# FIXME: subprocess or thread
try:
self._collector.write_logs(archive=filepath, logbytes=0)
except:
success = False
self.popdown(True)
if not success:
title = _('Logs not captured')
msg = _('The logs could not be captured.')
notify = NotifyAlert()
notify.props.title = title
notify.props.msg = msg
notify.connect('response', _notify_response_cb, self._activity)
self._activity.add_alert(notify)
jobject = datastore.create()
metadata = {
'title': _('log-%s') % filename,
'title_set_by_user': '0',
'suggested_filename': filename,
'mime_type': 'application/zip',
}
for k, v in metadata.items():
jobject.metadata[k] = v
jobject.file_path = filepath
datastore.write(jobject)
self._last_log = jobject.object_id
jobject.destroy()
activity.show_object_in_journal(self._last_log)
os.remove(filepath)
window.set_cursor(old_cursor)
Gdk.flush()
开发者ID:sugarlabs,项目名称:log-activity,代码行数:46,代码来源:logviewer.py
示例18: show_accelerator_alert
def show_accelerator_alert(self):
self.grab_focus()
self._alert = NotifyAlert()
self._alert.props.title = _('Tablet mode detected.')
self._alert.props.msg = _('Hold your XO flat and tilt to play!')
self.add_alert(self._alert)
self._alert.connect('response', self._alert_cancel_cb)
self._alert.show()
开发者ID:godiard,项目名称:maze-activity,代码行数:8,代码来源:activity.py
示例19: _create_image
def _create_image(self, text):
fd = open('/tmp/cloud_data.txt', 'w')
data = json_dump({'repeat': self._repeat_tags,
'layout': self._layout,
'font': self._font_name,
'colors': self._color_scheme})
fd.write(data)
fd.close()
fd = open('/tmp/cloud_text.txt', 'w')
fd.write(text)
fd.close()
path = os.path.join('/tmp/cloud_large.png')
try:
subprocess.check_call(
[os.path.join(activity.get_bundle_path(), 'wordcloud.py')])
except subprocess.CalledProcessError as e:
self.get_window().set_cursor(
Gdk.Cursor.new(Gdk.CursorType.LEFT_PTR))
alert = NotifyAlert(5)
alert.props.title = _('WordCloud error')
logging.error(e)
logging.error(e.returncode)
if e.returncode == 255:
logging.error('STOP WORD ERROR')
MESSAGE = _('All of your words are "stop words."'
' Please try adding more words.')
else:
logging.error('MEMORY ERROR')
MESSAGE = _('Oops. There was a problem. Please try again.')
alert.props.msg = MESSAGE
alert.connect('response', self._remove_alert_cb)
self.add_alert(alert)
return
self.get_window().set_cursor(Gdk.Cursor.new(Gdk.CursorType.LEFT_PTR))
self._show_image(path)
dsobject = datastore.create()
dsobject.metadata['title'] = _('Word Cloud')
dsobject.metadata['icon-color'] = profile.get_color().to_string()
dsobject.metadata['mime_type'] = 'image/png'
dsobject.set_file_path(path)
datastore.write(dsobject)
dsobject.destroy()
开发者ID:sugarlabs,项目名称:wordcloud,代码行数:45,代码来源:activity.py
示例20: __init__
def __init__(self, handle):
''' Initiate activity. '''
super(FractionBounceActivity, self).__init__(handle)
self.nick = profile.get_nick_name()
if profile.get_color() is not None:
self._colors = profile.get_color().to_string().split(',')
else:
self._colors = ['#A0FFA0', '#FF8080']
self.max_participants = 4 # sharing
self._playing = True
self._setup_toolbars()
self._setup_dispatch_table()
canvas = self._setup_canvas()
# Read any custom fractions from the project metadata
if 'custom' in self.metadata:
custom = self.metadata['custom']
else:
custom = None
self._current_ball = 'soccerball'
self._toolbar_was_expanded = False
# Initialize the canvas
self._bounce_window = Bounce(canvas, activity.get_bundle_path(), self)
Gdk.Screen.get_default().connect('size-changed', self._configure_cb)
# Restore any custom fractions
if custom is not None:
fractions = custom.split(',')
for f in fractions:
self._bounce_window.add_fraction(f)
if self.shared_activity:
# We're joining
if not self.get_shared():
xocolors = XoColor(profile.get_color().to_string())
share_icon = Icon(icon_name='zoom-neighborhood',
xo_color=xocolors)
self._joined_alert = NotifyAlert()
self._joined_alert.props.icon = share_icon
self._joined_alert.props.title = _('Please wait')
self._joined_alert.props.msg = _('Starting connection...')
self._joined_alert.connect('response', self._alert_cancel_cb)
self.add_alert(self._joined_alert)
self._label.set_label(_('Wait for the sharer to start.'))
# Wait for joined signal
self.connect("joined", self._joined_cb)
self._setup_sharing()
开发者ID:leonardcj,项目名称:fractionbounce,代码行数:57,代码来源:FractionBounceActivity.py
注:本文中的sugar3.graphics.alert.NotifyAlert类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论