本文整理汇总了Python中sugar3.graphics.icon.Icon.connect方法的典型用法代码示例。如果您正苦于以下问题:Python Icon.connect方法的具体用法?Python Icon.connect怎么用?Python Icon.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sugar3.graphics.icon.Icon
的用法示例。
在下文中一共展示了Icon.connect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from sugar3.graphics.icon import Icon [as 别名]
# 或者: from sugar3.graphics.icon.Icon import connect [as 别名]
def __init__(self, model, alerts):
SectionView.__init__(self)
self._model = model
self.restart_alerts = alerts
services = get_webaccount_services()
grid = Gtk.Grid()
if len(services) == 0:
grid.set_row_spacing(style.DEFAULT_SPACING)
icon = Icon(pixel_size=style.LARGE_ICON_SIZE,
icon_name='module-webaccount',
stroke_color=style.COLOR_BUTTON_GREY.get_svg(),
fill_color=style.COLOR_TRANSPARENT.get_svg())
grid.attach(icon, 0, 0, 1, 1)
icon.show()
label = Gtk.Label()
label.set_justify(Gtk.Justification.CENTER)
label.set_markup(
'<span foreground="%s" size="large">%s</span>'
% (style.COLOR_BUTTON_GREY.get_html(),
GLib.markup_escape_text(
_('No web services are installed.\n'
'Please visit %s for more details.' %
'http://wiki.sugarlabs.org/go/WebServices'))))
label.show()
grid.attach(label, 0, 1, 1, 1)
alignment = Gtk.Alignment.new(0.5, 0.5, 0.1, 0.1)
alignment.add(grid)
grid.show()
self.add(alignment)
alignment.show()
return
grid.set_row_spacing(style.DEFAULT_SPACING * 4)
grid.set_column_spacing(style.DEFAULT_SPACING * 4)
grid.set_border_width(style.DEFAULT_SPACING * 2)
grid.set_column_homogeneous(True)
width = Gdk.Screen.width() - 2 * style.GRID_CELL_SIZE
nx = int(width / (style.GRID_CELL_SIZE + style.DEFAULT_SPACING * 4))
self._service_config_box = Gtk.VBox()
x = 0
y = 0
for service in services:
service_grid = Gtk.Grid()
icon = CanvasIcon(icon_name=service.get_icon_name())
icon.show()
service_grid.attach(icon, x, y, 1, 1)
icon.connect('activate', service.config_service_cb, None,
self._service_config_box)
label = Gtk.Label()
label.set_justify(Gtk.Justification.CENTER)
name = get_service_name(service)
label.set_markup(name)
service_grid.attach(label, x, y + 1, 1, 1)
label.show()
grid.attach(service_grid, x, y, 1, 1)
service_grid.show()
x += 1
if x == nx:
x = 0
y += 1
alignment = Gtk.Alignment.new(0.5, 0, 0, 0)
alignment.add(grid)
grid.show()
vbox = Gtk.VBox()
vbox.pack_start(alignment, False, False, 0)
alignment.show()
scrolled = Gtk.ScrolledWindow()
vbox.pack_start(scrolled, True, True, 0)
self.add(vbox)
scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
scrolled.show()
workspace = Gtk.VBox()
scrolled.add_with_viewport(workspace)
workspace.show()
workspace.add(self._service_config_box)
workspace.show_all()
vbox.show()
示例2: Sidebar
# 需要导入模块: from sugar3.graphics.icon import Icon [as 别名]
# 或者: from sugar3.graphics.icon.Icon import connect [as 别名]
class Sidebar(Gtk.EventBox):
def __init__(self):
Gtk.EventBox.__init__(self)
self.set_size_request(20, -1)
# Take care of the background first
white = Gdk.color_parse("white")
self.modify_bg(Gtk.StateType.NORMAL, white)
self._box = Gtk.VButtonBox()
self._box.set_layout(Gtk.ButtonBoxStyle.CENTER)
self.add(self._box)
self._box.show()
self.show()
self._view = None
self._bookmark_icon = None
self._bookmark_manager = None
self._is_showing_local_bookmark = False
self.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
def _add_bookmark_icon(self, bookmark):
xocolor = XoColor(bookmark.color)
self._bookmark_icon = Icon(icon_name='emblem-favorite', pixel_size=18,
xo_color=xocolor)
self._bookmark_icon.props.has_tooltip = True
self.__bookmark_icon_query_tooltip_cb_id = \
self._bookmark_icon.connect('query_tooltip',
self.__bookmark_icon_query_tooltip_cb, bookmark)
self.__event_cb_id = \
self.connect('event', self.__event_cb, bookmark)
self._box.pack_start(self._bookmark_icon, False, False, 0)
self._bookmark_icon.show_all()
if bookmark.is_local():
self._is_showing_local_bookmark = True
def __bookmark_icon_query_tooltip_cb(self, widget, x, y, keyboard_mode,
tip, bookmark):
tooltip_header = bookmark.get_note_title()
tooltip_body = bookmark.get_note_body()
#TRANS: This goes like Bookmark added by User 5 days ago
#TRANS: (the elapsed string gets translated automatically)
tooltip_footer = (_('Bookmark added by %(user)s %(time)s') \
% {'user': bookmark.nick,
'time': timestamp_to_elapsed_string(bookmark.timestamp)})
vbox = Gtk.VBox()
l = Gtk.Label('<big>%s</big>' % tooltip_header)
l.set_use_markup(True)
l.set_width_chars(40)
l.set_line_wrap(True)
vbox.pack_start(l, False, False, 0)
l.show()
l = Gtk.Label('%s' % tooltip_body)
l.set_use_markup(True)
l.set_alignment(0, 0)
l.set_padding(2, 6)
l.set_width_chars(40)
l.set_line_wrap(True)
l.set_justify(Gtk.Justification.FILL)
vbox.pack_start(l, True, True, 0)
l.show()
l = Gtk.Label('<small><i>%s</i></small>' % tooltip_footer)
l.set_use_markup(True)
l.set_width_chars(40)
l.set_line_wrap(True)
vbox.pack_start(l, False, False, 0)
l.show()
tip.set_custom(vbox)
return True
def __event_cb(self, widget, event, bookmark):
if event.type == Gdk.EventType.BUTTON_PRESS and \
self._bookmark_icon is not None:
bookmark_title = bookmark.get_note_title()
bookmark_content = bookmark.get_note_body()
dialog = BookmarkEditDialog(
parent_xid=self.get_toplevel().window.xid,
dialog_title=_("Add notes for bookmark: "),
bookmark_title=bookmark_title,
bookmark_content=bookmark_content, page=bookmark.page_no,
sidebarinstance=self)
dialog.show_all()
return False
#.........这里部分代码省略.........