本文整理汇总了Python中sugar.graphics.icon.Icon.show方法的典型用法代码示例。如果您正苦于以下问题:Python Icon.show方法的具体用法?Python Icon.show怎么用?Python Icon.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sugar.graphics.icon.Icon
的用法示例。
在下文中一共展示了Icon.show方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _object_chooser
# 需要导入模块: from sugar.graphics.icon import Icon [as 别名]
# 或者: from sugar.graphics.icon.Icon import show [as 别名]
def _object_chooser(self, mime_type, type_name):
chooser = ObjectChooser()
matches_mime_type = False
response = chooser.run()
if response == gtk.RESPONSE_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.RESPONSE_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']
示例2: __init__
# 需要导入模块: from sugar.graphics.icon import Icon [as 别名]
# 或者: from sugar.graphics.icon.Icon import show [as 别名]
def __init__(self, text_label=None, icon_name=None, text_maxlen=60,
xo_color=None, file_name=None, image=None):
super(MenuItem, self).__init__()
self._accelerator = None
self.props.submenu = None
label = gtk.AccelLabel(text_label)
label.set_alignment(0.0, 0.5)
label.set_accel_widget(self)
if text_maxlen > 0:
label.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
label.set_max_width_chars(text_maxlen)
self.add(label)
label.show()
if image is not None:
self.set_image(image)
image.show()
elif icon_name is not None:
icon = Icon(icon_name=icon_name,
icon_size=gtk.ICON_SIZE_SMALL_TOOLBAR)
if xo_color is not None:
icon.props.xo_color = xo_color
self.set_image(icon)
icon.show()
elif file_name is not None:
icon = Icon(file=file_name, icon_size=gtk.ICON_SIZE_SMALL_TOOLBAR)
if xo_color is not None:
icon.props.xo_color = xo_color
self.set_image(icon)
icon.show()
示例3: setup_palette
# 需要导入模块: from sugar.graphics.icon import Icon [as 别名]
# 或者: from sugar.graphics.icon.Icon import show [as 别名]
def setup_palette(self):
title = self._home_activity.get_title()
self.set_primary_text(glib.markup_escape_text(title))
vbox = gtk.VBox()
self.set_content(vbox)
vbox.show()
self._progress_bar = gtk.ProgressBar()
vbox.add(self._progress_bar)
self._progress_bar.show()
self._free_space_label = gtk.Label()
self._free_space_label.set_alignment(0.5, 0.5)
vbox.add(self._free_space_label)
self._free_space_label.show()
self.connect('popup', self.__popup_cb)
menu_item = MenuItem(_('Show contents'))
icon = Icon(file=self._home_activity.get_icon_path(),
icon_size=gtk.ICON_SIZE_MENU,
xo_color=self._home_activity.get_icon_color())
menu_item.set_image(icon)
icon.show()
menu_item.connect('activate', self.__open_activate_cb)
self.menu.append(menu_item)
menu_item.show()
示例4: __init__
# 需要导入模块: from sugar.graphics.icon import Icon [as 别名]
# 或者: from sugar.graphics.icon.Icon import show [as 别名]
def __init__(self, text_label=None, icon_name=None, text_maxlen=60,
xo_color=None, file_name=None):
gobject.GObject.__init__(self)
self._accelerator = None
label = gtk.AccelLabel(text_label)
label.set_alignment(0.0, 0.5)
label.set_accel_widget(self)
if text_maxlen > 0:
label.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
label.set_max_width_chars(text_maxlen)
self.add(label)
label.show()
if icon_name is not None:
icon = Icon(icon_name=icon_name,
icon_size=gtk.ICON_SIZE_SMALL_TOOLBAR)
if xo_color is not None:
icon.props.xo_color = xo_color
self.set_image(icon)
icon.show()
elif file_name is not None:
icon = Icon(file=file_name, icon_size=gtk.ICON_SIZE_SMALL_TOOLBAR)
if xo_color is not None:
icon.props.xo_color = xo_color
self.set_image(icon)
icon.show()
self.connect('can-activate-accel', self.__can_activate_accel_cb)
self.connect('hierarchy-changed', self.__hierarchy_changed_cb)
示例5: __init__
# 需要导入模块: from sugar.graphics.icon import Icon [as 别名]
# 或者: from sugar.graphics.icon.Icon import show [as 别名]
def __init__(self, mount):
Palette.__init__(self, label=mount.get_name())
self._mount = mount
path = mount.get_root().get_path()
self.props.secondary_text = glib.markup_escape_text(path)
vbox = gtk.VBox()
self.set_content(vbox)
vbox.show()
self._progress_bar = gtk.ProgressBar()
vbox.add(self._progress_bar)
self._progress_bar.show()
self._free_space_label = gtk.Label()
self._free_space_label.set_alignment(0.5, 0.5)
vbox.add(self._free_space_label)
self._free_space_label.show()
self.connect('popup', self.__popup_cb)
menu_item = MenuItem(pgettext('Volume', 'Remove'))
icon = Icon(icon_name='media-eject', icon_size=gtk.ICON_SIZE_MENU)
menu_item.set_image(icon)
icon.show()
menu_item.connect('activate', self.__unmount_activate_cb)
self.menu.append(menu_item)
menu_item.show()
示例6: __init__
# 需要导入模块: from sugar.graphics.icon import Icon [as 别名]
# 或者: from sugar.graphics.icon.Icon import show [as 别名]
def __init__(self, file_name, document_path, title):
RadioToolButton.__init__(self)
self._document_path = document_path
self._title = title
self._jobject = None
self.props.tooltip = _('Instance Source')
client = gconf.client_get_default()
self._color = client.get_string('/desktop/sugar/user/color')
icon = Icon(file=file_name,
icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR,
xo_color=XoColor(self._color))
self.set_icon_widget(icon)
icon.show()
menu_item = MenuItem(_('Keep'))
icon = Icon(icon_name='document-save', icon_size=gtk.ICON_SIZE_MENU,
xo_color=XoColor(self._color))
menu_item.set_image(icon)
menu_item.connect('activate', self.__keep_in_journal_cb)
self.props.palette.menu.append(menu_item)
menu_item.show()
示例7: _value_changed
# 需要导入模块: from sugar.graphics.icon import Icon [as 别名]
# 或者: from sugar.graphics.icon.Icon 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.RESPONSE_OK, _('Ok'), ok_icon)
ok_icon.show()
alert.connect('response', lambda a, r: activity.remove_alert(a))
activity.add_alert(alert)
alert.show()
示例8: __init__
# 需要导入模块: from sugar.graphics.icon import Icon [as 别名]
# 或者: from sugar.graphics.icon.Icon import show [as 别名]
def __init__(self):
gtk.Window.__init__(self)
self.set_border_width(style.LINE_WIDTH)
offset = style.GRID_CELL_SIZE
width = gtk.gdk.screen_width() - offset * 2
height = gtk.gdk.screen_height() - offset * 2
self.set_size_request(width, height)
self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
self.set_decorated(False)
self.set_resizable(False)
self.set_modal(True)
self._main_view = gtk.EventBox()
self._vbox = gtk.VBox()
self._vbox.set_spacing(style.DEFAULT_SPACING)
self._vbox.set_border_width(style.GRID_CELL_SIZE * 2)
self._main_view.modify_bg(gtk.STATE_NORMAL,
style.COLOR_BLACK.get_gdk_color())
self._main_view.add(self._vbox)
self._vbox.show()
client = gconf.client_get_default()
color = XoColor(client.get_string('/desktop/sugar/user/color'))
icon = Icon(icon_name='activity-journal',
pixel_size=style.XLARGE_ICON_SIZE,
xo_color=color)
self._vbox.pack_start(icon, False)
icon.show()
self._title = gtk.Label()
self._title.modify_fg(gtk.STATE_NORMAL,
style.COLOR_WHITE.get_gdk_color())
self._title.set_markup('<b>%s</b>' % _('Your Journal is full'))
self._vbox.pack_start(self._title, False)
self._title.show()
self._message = gtk.Label(_('Please delete some old Journal'
' entries to make space for new ones.'))
self._message.modify_fg(gtk.STATE_NORMAL,
style.COLOR_WHITE.get_gdk_color())
self._vbox.pack_start(self._message, False)
self._message.show()
alignment = gtk.Alignment(xalign=0.5, yalign=0.5)
self._vbox.pack_start(alignment, expand=False)
alignment.show()
self._show_journal = gtk.Button()
self._show_journal.set_label(_('Show Journal'))
alignment.add(self._show_journal)
self._show_journal.show()
self._show_journal.connect('clicked', self.__show_journal_cb)
self.add(self._main_view)
self._main_view.show()
self.connect('realize', self.__realize_cb)
示例9: InlineAlert
# 需要导入模块: from sugar.graphics.icon import Icon [as 别名]
# 或者: from sugar.graphics.icon.Icon import show [as 别名]
class InlineAlert(gtk.HBox):
"""UI interface for Inline alerts
Inline alerts are different from the other alerts beause they are
no dialogs, they only inform about a current event.
Properties:
'msg': the message of the alert,
'icon': the icon that appears at the far left
See __gproperties__
"""
__gtype_name__ = 'SugarInlineAlert'
__gproperties__ = {
'msg': (str, None, None, None, gobject.PARAM_READWRITE),
'icon': (object, None, None, gobject.PARAM_WRITABLE),
}
def __init__(self, **kwargs):
self._msg = None
self._msg_color = None
self._icon = Icon(icon_name='emblem-warning',
fill_color=style.COLOR_SELECTION_GREY.get_svg(),
stroke_color=style.COLOR_WHITE.get_svg())
self._msg_label = gtk.Label()
self._msg_label.set_max_width_chars(50)
self._msg_label.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
self._msg_label.set_alignment(0, 0.5)
self._msg_label.modify_fg(gtk.STATE_NORMAL,
style.COLOR_SELECTION_GREY.get_gdk_color())
gobject.GObject.__init__(self, **kwargs)
self.set_spacing(style.DEFAULT_SPACING)
self.modify_bg(gtk.STATE_NORMAL,
style.COLOR_WHITE.get_gdk_color())
self.pack_start(self._icon, False)
self.pack_start(self._msg_label, False)
self._msg_label.show()
self._icon.show()
def do_set_property(self, pspec, value):
if pspec.name == 'msg':
if self._msg != value:
self._msg = value
self._msg_label.set_markup(self._msg)
elif pspec.name == 'icon':
if self._icon != value:
self._icon = value
def do_get_property(self, pspec):
if pspec.name == 'msg':
return self._msg
示例10: refresh
# 需要导入模块: from sugar.graphics.icon import Icon [as 别名]
# 或者: from sugar.graphics.icon.Icon import show [as 别名]
def refresh(self,widget=None):
default, uri = self.load_license()
icon_name = self.uri_to_icon(uri)
logging.debug("Refreshing ToolButton Icon")
icon = Icon(icon_name,icon_size=self._icon_size,xo_color=XoColor("#ffffff,#ffffff"))
icon.show()
self.set_icon_widget(icon)
self.set_tooltip(self._format_tooltip(uri))
self.make_menu(self.get_palette(),XoColor("#ffffff,#ffffff"),self._color_selected,icon)
示例11: __init__
# 需要导入模块: from sugar.graphics.icon import Icon [as 别名]
# 或者: from sugar.graphics.icon.Icon import show [as 别名]
def __init__(self, **kwargs):
Alert.__init__(self, **kwargs)
icon = Icon(icon_name='dialog-cancel')
self.add_button(gtk.RESPONSE_CANCEL, _('Cancel'), icon)
icon.show()
icon = Icon(icon_name='dialog-ok')
self.add_button(gtk.RESPONSE_OK, _('Ok'), icon)
icon.show()
示例12: add_action
# 需要导入模块: from sugar.graphics.icon import Icon [as 别名]
# 或者: from sugar.graphics.icon.Icon import show [as 别名]
def add_action(self, label, icon_name=None):
button = gtk.Button(label)
if icon_name:
icon = Icon(icon_name)
button.set_image(icon)
icon.show()
self.pack_start(button)
button.show()
示例13: __init__
# 需要导入模块: from sugar.graphics.icon import Icon [as 别名]
# 或者: from sugar.graphics.icon.Icon import show [as 别名]
def __init__(self, activity):
gtk.Toolbar.__init__(self)
self._activity = activity
self._updating_share = False
self._focus_out_hid = None
activity.connect('shared', self.__activity_shared_cb)
activity.connect('joined', self.__activity_shared_cb)
activity.connect('notify::max_participants',
self.__max_participants_changed_cb)
if activity.metadata:
self.title = gtk.Entry()
self.title.set_size_request(int(gtk.gdk.screen_width() / 3), -1)
self.title.set_text(activity.metadata['title'])
self._focus_out_hid = self.title.connect('focus-out-event',
self.__title_changed_cb)
self._add_widget(self.title)
activity.metadata.connect('updated', self.__jobject_updated_cb)
separator = gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_expand(True)
self.insert(separator, -1)
separator.show()
self.share = ToolComboBox(label_text=_('Share with:'))
self.share.combo.connect('changed', self.__share_changed_cb)
self.share.combo.append_item(SCOPE_PRIVATE, _('Private'), 'zoom-home')
self.share.combo.append_item(SCOPE_NEIGHBORHOOD, _('My Neighborhood'),
'zoom-neighborhood')
self.insert(self.share, -1)
self.share.show()
self._update_share()
self.keep = ToolButton(tooltip=_('Keep'))
client = gconf.client_get_default()
color = XoColor(client.get_string('/desktop/sugar/user/color'))
keep_icon = Icon(icon_name='document-save', xo_color=color)
self.keep.set_icon_widget(keep_icon)
keep_icon.show()
self.keep.props.accelerator = '<Ctrl>S'
self.keep.connect('clicked', self.__keep_clicked_cb)
self.insert(self.keep, -1)
self.keep.show()
self.stop = ToolButton('activity-stop', tooltip=_('Stop'))
self.stop.props.accelerator = '<Ctrl>Q'
self.stop.connect('clicked', self.__stop_clicked_cb)
self.insert(self.stop, -1)
self.stop.show()
示例14: _add_playback_button
# 需要导入模块: from sugar.graphics.icon import Icon [as 别名]
# 或者: from sugar.graphics.icon.Icon import show [as 别名]
def _add_playback_button(self, nick, colors, audio_file):
''' Add a toolbar button for this audio recording '''
if nick not in self._playback_buttons:
self._playback_buttons[nick] = button_factory(
'xo-chat', self.record_toolbar,
self._playback_recording_cb, cb_arg=nick,
tooltip=_('Audio recording by %s') % (nick))
xocolor = XoColor('%s,%s' % (colors[0], colors[1]))
icon = Icon(icon_name='xo-chat', xo_color=xocolor)
icon.show()
self._playback_buttons[nick].set_icon_widget(icon)
self._playback_buttons[nick].show()
self._audio_recordings[nick] = audio_file
示例15: __init__
# 需要导入模块: from sugar.graphics.icon import Icon [as 别名]
# 或者: from sugar.graphics.icon.Icon import show [as 别名]
def __init__(self):
label = glib.markup_escape_text(_('Wireless modem'))
Palette.__init__(self, primary_text=label)
self._current_state = None
self._failed_connection = False
self._toggle_state_item = MenuItem('')
self._toggle_state_item.connect('activate', self.__toggle_state_cb)
self.menu.append(self._toggle_state_item)
self._toggle_state_item.show()
self.info_box = gtk.VBox()
self.error_title_label = gtk.Label("")
self.error_title_label.set_alignment(0, 0.5)
self.error_title_label.set_line_wrap(True)
self.info_box.pack_start(self.error_title_label)
self.error_description_label = gtk.Label("")
self.error_description_label.set_alignment(0, 0.5)
self.error_description_label.set_line_wrap(True)
self.info_box.pack_start(self.error_description_label)
self.connection_info_box = gtk.HBox()
icon = Icon(icon_name='data-upload', icon_size=gtk.ICON_SIZE_MENU)
self.connection_info_box.pack_start(icon)
icon.show()
self._data_label_up = gtk.Label()
self._data_label_up.props.xalign = 0.0
label_alignment = self._add_widget_with_padding(self._data_label_up)
self.connection_info_box.pack_start(label_alignment)
self._data_label_up.show()
label_alignment.show()
icon = Icon(icon_name='data-download', icon_size=gtk.ICON_SIZE_MENU)
self.connection_info_box.pack_start(icon)
icon.show()
self._data_label_down = gtk.Label()
self._data_label_down.props.xalign = 0.0
label_alignment = self._add_widget_with_padding(self._data_label_down)
self.connection_info_box.pack_start(label_alignment)
self._data_label_down.show()
label_alignment.show()
self.info_box.pack_start(self.connection_info_box)
self.info_box.show()
self.set_content(self.info_box)
self.set_state(_GSM_STATE_NOT_READY)