本文整理汇总了Python中sugar.graphics.icon.Icon类的典型用法代码示例。如果您正苦于以下问题:Python Icon类的具体用法?Python Icon怎么用?Python Icon使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Icon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
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()
示例2: _value_changed
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()
示例3: setup_palette
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__
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()
示例5: _object_chooser
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']
示例6: __init__
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)
示例7: InlineAlert
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
示例8: refresh
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)
示例9: add_action
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()
示例10: __init__
def __init__(self, **kwargs):
self._pulser = Pulser(self)
self._base_color = None
self._pulse_color = None
self._paused = False
self._pulsing = False
Icon.__init__(self, **kwargs)
self._palette = None
self.connect('destroy', self.__destroy_cb)
示例11: __init__
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()
示例12: _add_playback_button
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
示例13: EventIcon
class EventIcon(gtk.EventBox):
__gtype_name__ = 'SugarEventIcon'
def __init__(self, **kwargs):
gtk.EventBox.__init__(self)
self.icon = Icon(pixel_size=style.XLARGE_ICON_SIZE, **kwargs)
self.set_visible_window(False)
self.set_app_paintable(True)
self.set_events(gtk.gdk.BUTTON_PRESS_MASK)
self.add(self.icon)
self.icon.show()
示例14: __init__
def __init__(self, activity, **kwargs):
ToolButton.__init__(self, **kwargs)
logging.warning('KeepButton has been deprecated since Sugar 0.94'
' and should not be used in newly written code.')
self.props.tooltip = _('Keep')
self.props.accelerator = '<Ctrl>S'
client = gconf.client_get_default()
color = XoColor(client.get_string('/desktop/sugar/user/color'))
keep_icon = Icon(icon_name='document-save', xo_color=color)
keep_icon.show()
self.set_icon_widget(keep_icon)
self.connect('clicked', self.__keep_button_clicked_cb, activity)
示例15: __init__
def __init__(self, timeout=5, **kwargs):
Alert.__init__(self, **kwargs)
self._timeout = timeout
icon = Icon(icon_name='dialog-cancel')
self.add_button(gtk.RESPONSE_CANCEL, _('Cancel'), icon)
icon.show()
self._timeout_text = _TimeoutIcon()
self._timeout_text.set_text(self._timeout)
self.add_button(gtk.RESPONSE_OK, _('Continue'), self._timeout_text)
self._timeout_text.show()
gobject.timeout_add_seconds(1, self.__timeout)