本文整理汇总了Python中sugar3.graphics.icon.Icon类的典型用法代码示例。如果您正苦于以下问题:Python Icon类的具体用法?Python Icon怎么用?Python Icon使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Icon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
ToolButton.__init__(self)
self._property = 'timestamp'
self._order = Gtk.SortType.ASCENDING
self.props.tooltip = _('Sort view')
self.props.icon_name = 'view-lastedit'
self.props.hide_tooltip_on_click = False
self.palette_invoker.props.toggle_palette = True
menu_box = PaletteMenuBox()
self.props.palette.set_content(menu_box)
menu_box.show()
sort_options = [
('timestamp', 'view-lastedit', _('Sort by date modified')),
('creation_time', 'view-created', _('Sort by date created')),
('filesize', 'view-size', _('Sort by size')),
]
for property_, icon, label in sort_options:
button = PaletteMenuItem(label)
button_icon = Icon(pixel_size=style.SMALL_ICON_SIZE,
icon_name=icon)
button.set_image(button_icon)
button_icon.show()
button.connect('activate',
self.__sort_type_changed_cb,
property_,
icon)
button.show()
menu_box.append_item(button)
示例2: __init__
def __init__(self, icon_name):
Gtk.Button.__init__(self)
self.modify_bg(
Gtk.StateType.NORMAL,
style.COLOR_TOOLBAR_GREY.get_gdk_color())
self.modify_bg(
Gtk.StateType.ACTIVE,
style.COLOR_BUTTON_GREY.get_gdk_color())
self.set_relief(Gtk.ReliefStyle.NONE)
self.set_size_request(
style.GRID_CELL_SIZE,
style.GRID_CELL_SIZE)
icon = Icon(
icon_name = icon_name,
icon_size = Gtk.IconSize.SMALL_TOOLBAR)
self.set_image(icon)
icon.show()
self.show_all()
#self.connect('clicked', self._clicked_cb)
示例3: add_radio_buttons
def add_radio_buttons(self, button_icons, colors=None):
# Psuedo-radio buttons
alignment = Gtk.Alignment.new(0.5, 0.5, 0, 0)
grid = Gtk.Grid()
grid.set_row_spacing(style.DEFAULT_SPACING)
grid.set_column_spacing(style.DEFAULT_SPACING)
grid.set_border_width(style.DEFAULT_SPACING * 2)
buttons = []
for i, button_icon in enumerate(button_icons):
if colors is not None:
icon = Icon(pixel_size=style.STANDARD_ICON_SIZE,
icon_name=button_icon,
stroke_color=colors.get_stroke_color(),
fill_color=colors.get_fill_color())
else:
icon = Icon(pixel_size=style.STANDARD_ICON_SIZE,
icon_name=button_icon)
buttons.append(Gtk.Button())
buttons[i].set_image(icon)
icon.show()
grid.attach(buttons[i], i, 0, 1, 1)
buttons[i].show()
alignment.add(grid)
grid.show()
self._attach(alignment)
alignment.show()
return buttons
示例4: __init__
def __init__(self, *args, **kwargs):
super(_StuckStrip, self).__init__(*args, **kwargs)
self.orientation = Gtk.Orientation.HORIZONTAL
spacer1 = Gtk.Label(label='')
self.pack_start(spacer1, True, True, 0)
spacer2 = Gtk.Label(label='')
self.pack_end(spacer2, expand=True, fill=False, padding=0)
self.set_spacing(10)
self.set_border_width(10)
label = Gtk.Label(label=_("Stuck? You can still solve the puzzle."))
self.pack_start(label, False, True, 0)
icon = Icon()
icon.set_from_icon_name('edit-undo', Gtk.IconSize.LARGE_TOOLBAR)
self.button = Gtk.Button(stock=Gtk.STOCK_UNDO)
self.button.set_image(icon)
self.button.set_label(_("Undo some moves"))
self.pack_end(self.button, expand=False, fill=False, padding=0)
def callback(source):
self.emit('undo-clicked')
self.button.connect('clicked', callback)
示例5: __init__
def __init__(self, child, label=""):
GObject.GObject.__init__(self)
self._child = child
self._label = Gtk.Label(label=label)
self._label.set_alignment(0, 0.5)
self.pack_start(self._label, True, True, 0)
self._label.show()
#self.modify_base(Gtk.StateType.NORMAL, Gdk.Color(0, 0, 0, 1))
close_tab_icon = Icon(icon_name='close-tab')
button = Gtk.Button()
button.props.relief = Gtk.ReliefStyle.NONE
button.props.focus_on_click = False
icon_box = Gtk.HBox()
icon_box.pack_start(close_tab_icon, True, False, 0)
button.add(icon_box)
button.connect('clicked', self.__button_clicked_cb)
button.set_name('browse-tab-close')
self.pack_start(button, False, True, 0)
close_tab_icon.show()
icon_box.show()
button.show()
self._close_button = button
示例6: _IconWidget
class _IconWidget(Gtk.EventBox):
__gtype_name__ = 'SugarTrayIconWidget'
def __init__(self, icon_name=None, xo_color=None):
GObject.GObject.__init__(self)
self.set_app_paintable(True)
self.add_events(Gdk.EventMask.BUTTON_PRESS_MASK |
Gdk.EventMask.TOUCH_MASK |
Gdk.EventMask.BUTTON_RELEASE_MASK)
self._icon = Icon(icon_name=icon_name, xo_color=xo_color,
icon_size=Gtk.IconSize.LARGE_TOOLBAR)
self.add(self._icon)
self._icon.show()
def do_draw(self, cr):
palette = self.get_parent().palette
if palette and palette.is_up():
invoker = palette.props.invoker
invoker.draw_rectangle(cr, palette)
Gtk.EventBox.do_draw(self, cr)
def get_icon(self):
return self._icon
示例7: __init__
def __init__(self, activity):
Gtk.EventBox.__init__(self)
self._area = Gtk.DrawingArea()
self._area.connect('draw', self._area_draw_cb)
self._boxes = []
self._current_box = None
prev_btn = Gtk.EventBox()
prev_btn.connect('button-press-event', self._prev_slide)
self._prev_icon = Icon(pixel_size=100)
self._prev_icon.props.icon_name = 'go-previous'
prev_btn.add(self._prev_icon)
next_btn = Gtk.EventBox()
next_btn.connect('button-press-event', self._next_slide)
self._next_icon = Icon(pixel_size=100)
self._next_icon.props.icon_name = 'go-next'
next_btn.add(self._next_icon)
hbox = Gtk.Box()
hbox.set_border_width(10)
hbox.pack_start(prev_btn, True, False, 0)
hbox.pack_start(self._area, False, False, 0)
hbox.pack_end(next_btn, True, False, 0)
self.add(hbox)
self.show_all()
示例8: _update_invite_menu
def _update_invite_menu(self, activity):
buddy_activity = self._buddy.props.current_activity
if buddy_activity is not None:
buddy_activity_id = buddy_activity.activity_id
else:
buddy_activity_id = None
self._invite_menu.hide()
if activity is None or \
activity.is_journal() or \
activity.get_activity_id() == buddy_activity_id:
return
bundle_activity = ActivityBundle(activity.get_bundle_path())
if bundle_activity.get_max_participants() > 1:
title = activity.get_title()
self._invite_menu.set_label(_('Invite to %s') % title)
icon = Icon(file=activity.get_icon_path(),
pixel_size=style.SMALL_ICON_SIZE)
icon.props.xo_color = activity.get_icon_color()
self._invite_menu.set_image(icon)
icon.show()
self._invite_menu.show()
示例9: add_text_icon_and_button
def add_text_icon_and_button(self, text, icon_name,
button_icon=None,
button_label=None,
size='large', bold=False,
color=style.COLOR_BLACK.get_html(),
justify=Gtk.Justification.LEFT,
stroke=style.COLOR_BUTTON_GREY.get_svg(),
fill=style.COLOR_TRANSPARENT.get_svg(),
icon_size=style.XLARGE_ICON_SIZE):
label = Gtk.Label()
label.set_use_markup(True)
label.set_justify(justify)
if bold:
text = '<b>' + text + '</b>'
span = '<span foreground="%s" size="%s">' % (color, size)
label.set_markup(span + text + '</span>')
icon = Icon(pixel_size=icon_size, icon_name=icon_name,
stroke_color=stroke, fill_color=fill)
if button_icon is not None:
button = ToolButton(button_icon)
else:
button = Gtk.Button()
button.set_label(button_label)
self._attach_three(label, icon, button)
label.show()
icon.show()
button.show()
return button
示例10: can_close
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
示例11: __init__
def __init__(self, file_name, document_path, activity_name, title,
bundle=False):
RadioToolButton.__init__(self)
self._document_path = document_path
self._title = title
self._jobject = None
self._activity_name = activity_name
self.props.tooltip = _('Instance Source')
settings = Gio.Settings('org.sugarlabs.user')
self._color = settings.get_string('color')
icon = Icon(file=file_name,
pixel_size=style.STANDARD_ICON_SIZE,
xo_color=XoColor(self._color))
self.set_icon_widget(icon)
icon.show()
box = PaletteMenuBox()
self.props.palette.set_content(box)
box.show()
if bundle:
menu_item = PaletteMenuItem(_('Duplicate'), 'edit-duplicate',
xo_color=XoColor(self._color))
menu_item.connect('activate', self.__show_duplicate_alert)
else:
menu_item = PaletteMenuItem(_('Keep'), 'document-save',
xo_color=XoColor(self._color))
menu_item.connect('activate', self.__keep_in_journal_cb)
box.append_item(menu_item)
menu_item.show()
示例12: _object_chooser
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']
示例13: __init__
def __init__(self, browser):
GObject.GObject.__init__(self)
browser.connect('notify::title', self.__title_changed_cb)
browser.connect('notify::load-status', self.__load_status_changed_cb)
self._title = _('Untitled')
self._label = Gtk.Label(label=self._title)
self._label.set_ellipsize(Pango.EllipsizeMode.END)
self._label.set_alignment(0, 0.5)
self.pack_start(self._label, True, True, 0)
self._label.show()
close_tab_icon = Icon(icon_name='browse-close-tab')
button = Gtk.Button()
button.props.relief = Gtk.ReliefStyle.NONE
button.props.focus_on_click = False
icon_box = Gtk.HBox()
icon_box.pack_start(close_tab_icon, True, False, 0)
button.add(icon_box)
button.connect('clicked', self.__button_clicked_cb)
button.set_name('browse-tab-close')
self.pack_start(button, False, True, 0)
close_tab_icon.show()
icon_box.show()
button.show()
self._close_button = button
示例14: __init__
def __init__(self, file_name, document_path, title, bundle=False):
RadioToolButton.__init__(self)
self._document_path = document_path
self._title = title
self._jobject = None
self.props.tooltip = _('Instance Source')
settings = Gio.Settings('org.sugarlabs.user')
self._color = settings.get_string('color')
icon = Icon(file=file_name,
pixel_size=style.STANDARD_ICON_SIZE,
xo_color=XoColor(self._color))
self.set_icon_widget(icon)
icon.show()
if bundle:
menu_item = MenuItem(_('Duplicate'))
icon = Icon(icon_name='edit-duplicate',
pixel_size=style.SMALL_ICON_SIZE,
xo_color=XoColor(self._color))
menu_item.connect('activate', self.__copy_to_home_cb)
else:
menu_item = MenuItem(_('Keep'))
icon = Icon(icon_name='document-save',
pixel_size=style.SMALL_ICON_SIZE,
xo_color=XoColor(self._color))
menu_item.connect('activate', self.__keep_in_journal_cb)
menu_item.set_image(icon)
self.props.palette.menu.append(menu_item)
menu_item.show()
示例15: __init__
def __init__(self, file_name, document_path, title, bundle=False):
RadioToolButton.__init__(self)
self._document_path = document_path
self._title = title
self._jobject = None
self.props.tooltip = _("Instance Source")
settings = Gio.Settings("org.sugarlabs.user")
self._color = settings.get_string("color")
icon = Icon(file=file_name, icon_size=Gtk.IconSize.LARGE_TOOLBAR, xo_color=XoColor(self._color))
self.set_icon_widget(icon)
icon.show()
if bundle:
menu_item = MenuItem(_("Duplicate"))
icon = Icon(icon_name="edit-duplicate", icon_size=Gtk.IconSize.MENU, xo_color=XoColor(self._color))
menu_item.connect("activate", self.__copy_to_home_cb)
else:
menu_item = MenuItem(_("Keep"))
icon = Icon(icon_name="document-save", icon_size=Gtk.IconSize.MENU, xo_color=XoColor(self._color))
menu_item.connect("activate", self.__keep_in_journal_cb)
menu_item.set_image(icon)
self.props.palette.menu.append(menu_item)
menu_item.show()