本文整理汇总了Python中sugar3.graphics.icon.EventIcon类的典型用法代码示例。如果您正苦于以下问题:Python EventIcon类的具体用法?Python EventIcon怎么用?Python EventIcon使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EventIcon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, picker):
EventIcon.__init__(self, icon_name='computer-xo',
pixel_size=style.LARGE_ICON_SIZE)
self._picker = picker
self._color = None
self.connect('activate', self.__activate_cb, picker)
示例2: Picker
class Picker(Gtk.Grid):
def __init__(self, icon, label):
Gtk.Grid.__init__(self)
self._button = EventIcon(pixel_size=style.LARGE_ICON_SIZE,
icon_name=icon)
self.attach(self._button, 0, 0, 1, 1)
self._button.hide()
self._label = Gtk.Label(label)
self.attach(self._label, 0, 1, 1, 1)
self._label.hide()
def show_all(self):
self._button.show()
self._label.show()
self.show()
def hide_all(self):
self._button.hide()
self._label.hide()
self.hide()
def connect(self, callback, arg):
self._button.connect('button-press-event', callback, arg)
def set_color(self, color):
self._button.xo_color = color
def set_icon(self, icon):
self._button.set_icon_name(icon)
示例3: Picker
class Picker(Gtk.Grid):
def __init__(self, icon, label):
Gtk.Grid.__init__(self)
self._button = EventIcon(pixel_size=style.LARGE_ICON_SIZE,
icon_name=icon)
self.attach(self._button, 0, 0, 1, 1)
self._button.hide()
self._label = Gtk.Label(label.replace(' ', '\n'))
self._label.props.justify = Gtk.Justification.CENTER
self.attach(self._label, 0, 1, 1, 1)
self._label.hide()
def show_all(self):
self._button.show()
self._label.show()
self.show()
def hide_all(self):
self._button.hide()
self._label.hide()
self.hide()
def connect(self, callback, arg):
self._button.connect('activate', callback, arg)
def set_color(self, color):
self._button.xo_color = color
def set_icon(self, icon):
self._button.set_icon_name(icon)
示例4: __init__
def __init__(self, picker):
EventIcon.__init__(self, icon_name='computer-xo',
pixel_size=style.LARGE_ICON_SIZE)
self._picker = picker
self._color = None
self.connect('button_press_event', self.__pressed_cb, picker)
示例5: _make_entry_widgets
def _make_entry_widgets(self):
'''We need to create a button for the smiley, a text entry, and a
send button.
All of this, along with the chatbox, goes into a grid.
---------------------------------------
| chat box |
| smiley button | entry | send button |
---------------------------------------
'''
if self._ebook_mode_detector.get_ebook_mode():
self._entry_height = int(style.GRID_CELL_SIZE * 1.5)
else:
self._entry_height = style.GRID_CELL_SIZE
entry_width = Gdk.Screen.width() - \
2 * (self._entry_height + style.GRID_CELL_SIZE)
self._chat_height = Gdk.Screen.height() - self._entry_height - \
style.GRID_CELL_SIZE
self._chat_width = Gdk.Screen.width()
self.chatbox.set_size_request(self._chat_width, self._chat_height)
self._entry_grid = Gtk.Grid()
self._entry_grid.set_size_request(
Gdk.Screen.width() - 2 * style.GRID_CELL_SIZE,
self._entry_height)
smiley_button = EventIcon(icon_name='smilies',
pixel_size=self._entry_height)
smiley_button.connect('button-press-event', self._smiley_button_cb)
self._entry_grid.attach(smiley_button, 0, 0, 1, 1)
smiley_button.show()
self._entry = Gtk.Entry()
self._entry.set_size_request(entry_width, self._entry_height)
self._entry.modify_bg(Gtk.StateType.INSENSITIVE,
style.COLOR_WHITE.get_gdk_color())
self._entry.modify_base(Gtk.StateType.INSENSITIVE,
style.COLOR_WHITE.get_gdk_color())
self._entry.set_sensitive(False)
self._entry.props.placeholder_text = \
_('You must be connected to a friend before starting to chat.')
self._entry.connect('focus-in-event', self._entry_focus_in_cb)
self._entry.connect('focus-out-event', self._entry_focus_out_cb)
self._entry.connect('activate', self._entry_activate_cb)
self._entry.connect('key-press-event', self._entry_key_press_cb)
self._entry_grid.attach(self._entry, 1, 0, 1, 1)
self._entry.show()
send_button = EventIcon(icon_name='send',
pixel_size=self._entry_height)
send_button.connect('button-press-event', self._send_button_cb)
self._entry_grid.attach(send_button, 2, 0, 1, 1)
send_button.show()
示例6: AgePicker
class AgePicker(Gtk.Grid):
age_changed_signal = GObject.Signal('age-changed',
arg_types=([int]))
def __init__(self, color, gender, age):
Gtk.Grid.__init__(self)
self._color = color
self._gender = gender
self._age = age
if self._gender is '':
# Used for graphic only; does not set user's gender preference.
self._gender = 'female'
self._icon = EventIcon(icon_name='%s-%d' % (self._gender, self._age),
pixel_size=style.LARGE_ICON_SIZE)
self._icon.connect('button-press-event', self.__pressed_cb)
self.attach(self._icon, 0, 0, 1, 1)
self._icon.show()
label = Gtk.Label()
label.set_text(AGE_LABELS[self._age])
self.attach(label, 0, 1, 1, 1)
label.show()
self.set_age()
def set_color(self, color, age):
self._color = color
self.set_age(age)
def set_age(self, age=None):
if age in AGES:
age_index = AGES.index(age)
else:
age_index = None
if age_index == self._age:
self._icon.props.xo_color = self._color
else:
self._icon.props.xo_color = _NOCOLOR
self._icon.show()
age = GObject.property(type=object, setter=set_age)
def set_gender(self, gender):
self._icon.set_icon_name('%s-%d' % (gender, self._age))
self._icon.show()
gender = GObject.property(type=object, setter=set_gender)
def __pressed_cb(self, button, event):
self.age_changed_signal.emit(self._age)
示例7: GenderPicker
class GenderPicker(Gtk.Grid):
gender_changed_signal = GObject.Signal('gender-changed', arg_types=([str]))
def __init__(self):
Gtk.Grid.__init__(self)
self.set_row_spacing(style.DEFAULT_SPACING)
self.set_column_spacing(style.DEFAULT_SPACING)
self._gender = load_gender()
self._buttons = []
self._nocolor = XoColor('#010101,#ffffff')
self._color = XoColor()
for i, gender in enumerate(GENDERS):
self._buttons.append(EventIcon(pixel_size=style.XLARGE_ICON_SIZE,
icon_name='%s-6' % (gender)))
self._buttons[-1].connect('button-press-event',
self._button_press_cb, i)
self.attach(self._buttons[-1], i * 2, 0, 1, 1)
self._buttons[-1].show()
self.reset_button = EventIcon(pixel_size=style.SMALL_ICON_SIZE,
icon_name='entry-cancel')
self.reset_button.connect('button-press-event',
self._reset_button_press_cb)
self.attach(self.reset_button, 1, 0, 1, 1)
self.reset_button.xo_color = XoColor('#010101,#a0a0a0')
self.reset_button.show()
def _reset_button_press_cb(self, widget, event):
self._set_gender('')
for i in range(len(GENDERS)):
self._buttons[i].xo_color = self._nocolor
def _button_press_cb(self, widget, event, gender_index):
if event.button == 1 and event.type == Gdk.EventType.BUTTON_PRESS:
self._set_gender(GENDERS[gender_index])
self._buttons[gender_index].xo_color = self._color
self._buttons[1 - gender_index].xo_color = self._nocolor
def get_gender(self):
return self._gender
def _set_gender(self, gender):
self.gender_changed_signal.emit(gender)
self._gender = gender
def update_color(self, color):
self._color = color
if self._gender in GENDERS:
self._buttons[GENDERS.index(self._gender)].xo_color = self._color
示例8: add_button
def add_button(self, icon_name, description, clicked_cb=None):
icon = EventIcon(icon_name=icon_name,
pixel_size=(style.GRID_CELL_SIZE*2)/5,
xo_color=XoColor('#ffffff,#ffffff'))
icon.props.palette = Palette(description)
self._top_bar.add(icon)
if clicked_cb:
def closure(widget, event):
alloc = widget.get_allocation()
if 0 < event.x < alloc.width and 0 < event.y < alloc.height:
clicked_cb(widget)
icon.connect('button-release-event', closure)
icon.show()
return icon
示例9: __init__
def __init__(self):
Gtk.Grid.__init__(self)
self.set_row_spacing(style.DEFAULT_SPACING)
self.set_column_spacing(style.DEFAULT_SPACING)
self._gender = load_gender()
self._buttons = []
self._nocolor = XoColor('#010101,#ffffff')
self._color = XoColor()
for i, gender in enumerate(GENDERS):
self._buttons.append(EventIcon(pixel_size=style.XLARGE_ICON_SIZE,
icon_name='%s-6' % (gender)))
self._buttons[-1].connect('button-press-event',
self._button_press_cb, i)
self.attach(self._buttons[-1], i * 2, 0, 1, 1)
self._buttons[-1].show()
self.reset_button = EventIcon(pixel_size=style.SMALL_ICON_SIZE,
icon_name='entry-cancel')
self.reset_button.connect('button-press-event',
self._reset_button_press_cb)
self.attach(self.reset_button, 1, 0, 1, 1)
self.reset_button.xo_color = XoColor('#010101,#a0a0a0')
self.reset_button.show()
示例10: _choose_activity
def _choose_activity(self):
if not hasattr(self, '_activity_sw'):
grid = Gtk.Grid()
self._reflection.activity.load_overlay_area(grid)
grid.show()
collapse_button = EventIcon(icon_name='delete', pixel_size=BUTTON_SIZE)
collapse_button.set_tooltip(_('Collapse'))
collapse_button.connect('button-press-event', self._reflection.activity.collapse_overlay_area)
grid.attach(collapse_button, 7, 0, 1, 1)
collapse_button.show()
bundle_icons = utils.get_bundle_icons()
x = 0
y = 1
for bundle_id in bundle_icons.keys():
icon_path = bundle_icons[bundle_id]
if icon_path is None:
continue
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
icon_path, style.GRID_CELL_SIZE, style.GRID_CELL_SIZE)
image = Gtk.Image.new_from_pixbuf(pixbuf)
button = Gtk.ToolButton()
button.set_icon_widget(image)
image.show()
button.connect('clicked', self._insert_activity, bundle_id)
grid.attach(button, x, y, 1, 1)
button.show()
x += 1
if x > 6:
y += 1
x = 0
self._reflection.activity.show_overlay_area()
self._reflection.activity.reset_cursor()
示例11: __init__
def __init__(self, icon, label):
Gtk.Grid.__init__(self)
self._button = EventIcon(pixel_size=style.LARGE_ICON_SIZE,
icon_name=icon)
self.attach(self._button, 0, 0, 1, 1)
self._button.hide()
self._label = Gtk.Label(label)
self.attach(self._label, 0, 1, 1, 1)
self._label.hide()
示例12: __init__
def __init__(self, icon, label):
Gtk.Grid.__init__(self)
self._button = EventIcon(pixel_size=style.LARGE_ICON_SIZE,
icon_name=icon)
self.attach(self._button, 0, 0, 1, 1)
self._button.hide()
self._label = Gtk.Label(label.replace(' ', '\n'))
self._label.props.justify = Gtk.Justification.CENTER
self.attach(self._label, 0, 1, 1, 1)
self._label.hide()
示例13: __init__
def __init__(self, placeholder=None):
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
self._button = EventIcon(icon_name='list-add')
self._button.connect('button-release-event',
self.__button_release_event_cb)
self._button.fill_color = style.COLOR_TOOLBAR_GREY.get_svg()
self._button.set_tooltip(_('Add New'))
self.pack_start(self._button, False, True, 0)
self._button.show()
self._entry = iconentry.IconEntry()
self._entry.connect('key-press-event', self.__key_press_cb)
if placeholder is None:
placeholder = _('Add new entry')
self._entry.set_placeholder_text(placeholder)
self._entry.add_clear_button()
self.pack_start(self._entry, True, True, 0)
self._entry.show()
示例14: AddNewBar
class AddNewBar(Gtk.Box):
activate = GObject.Signal('activate', arg_types=[str])
def __init__(self, placeholder=None):
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
self._button = EventIcon(icon_name='list-add')
self._button.connect('button-release-event',
self.__button_release_event_cb)
self._button.fill_color = style.COLOR_TOOLBAR_GREY.get_svg()
self._button.set_tooltip(_('Add New'))
self.pack_start(self._button, False, True, 0)
self._button.show()
self._entry = iconentry.IconEntry()
self._entry.connect('key-press-event', self.__key_press_cb)
if placeholder is None:
placeholder = _('Add new entry')
self._entry.set_placeholder_text(placeholder)
self._entry.add_clear_button()
self.pack_start(self._entry, True, True, 0)
self._entry.show()
def get_entry(self):
return self._entry
def get_button(self):
return self._button
def __key_press_cb(self, window, event):
if event.keyval == Gdk.KEY_Return:
return self._maybe_activate()
def __button_release_event_cb(self, button, event):
self._maybe_activate()
def _maybe_activate(self):
if self._entry.props.text:
self.activate.emit(self._entry.props.text)
self._entry.props.text = ''
return True
示例15: ReflectionGrid
class ReflectionGrid(Gtk.EventBox):
def __init__(self, parent):
Gtk.EventBox.__init__(self)
self._reflection = parent
self._collapse = True
self._collapse_id = None
self.modify_bg(Gtk.StateType.NORMAL, style.COLOR_WHITE.get_gdk_color())
self._title_color = self._reflection.activity.fg_color.get_html()
self._grid = Gtk.Grid()
self.add(self._grid)
self._grid.show()
self._grid.set_row_spacing(style.DEFAULT_PADDING)
self._grid.set_column_spacing(style.DEFAULT_SPACING)
self._grid.set_column_homogeneous(True)
self._grid.set_border_width(style.DEFAULT_PADDING)
row = 0
self._expand_button = EventIcon(icon_name="expand", pixel_size=BUTTON_SIZE)
self._collapse_id = self._expand_button.connect("button-press-event", self._expand_cb)
self._grid.attach(self._expand_button, 0, row, 1, 1)
self._expand_button.show()
self._title_align = Gtk.Alignment.new(xalign=0, yalign=0.5, xscale=0, yscale=0)
self._title = Gtk.TextView()
self._title.set_size_request(ENTRY_WIDTH, -1)
self._title.set_wrap_mode(Gtk.WrapMode.WORD)
self._title_tag = self._title.get_buffer().create_tag(
"title", foreground=self._title_color, weight=Pango.Weight.BOLD, size=12288
)
iter_text = self._title.get_buffer().get_iter_at_offset(0)
self._title.get_buffer().insert_with_tags(iter_text, self._reflection.data["title"], self._title_tag)
if self._reflection.activity.initiating:
self._title.connect("focus-out-event", self._title_focus_out_cb)
else:
self._title.set_editable(False)
self._title_align.add(self._title)
self._title.show()
self._grid.attach(self._title_align, 1, row, 5, 1)
self._title_align.show()
""" Notification that a new comment has been shared. """
self.notify_button = EventIcon(icon_name="chat", pixel_size=BUTTON_SIZE)
self._grid.attach(self.notify_button, 6, row, 1, 1)
row += 1
self._time_align = Gtk.Alignment.new(xalign=0, yalign=0.5, xscale=0, yscale=0)
self._time = Gtk.Label()
self._time.set_size_request(ENTRY_WIDTH, -1)
self._time.set_justify(Gtk.Justification.LEFT)
self._time.set_use_markup(True)
try:
time_string = util.timestamp_to_elapsed_string(int(self._reflection.data["modification_time"]))
except Exception as e:
logging.error(
"Could not convert modification time %s: %s" % (self._reflection.data["modification_time"], e)
)
self._reflection.data["modification_time"] = self._reflection.data["creation_time"]
time_string = util.timestamp_to_elapsed_string(int(self._reflection.data["modification_time"]))
self._time.set_markup('<span foreground="#808080"><small><b>%s</b></small></span>' % time_string)
self._time_align.add(self._time)
self._time.show()
self._grid.attach(self._time_align, 1, row, 5, 1)
self._time_align.show()
row += 1
label = ""
if "tags" in self._reflection.data:
for tag in self._reflection.data["tags"]:
if len(label) > 0:
label += ", "
label += tag
if self._reflection.activity.initiating and label == "":
label = _("Add a #tag")
self._tag_align = Gtk.Alignment.new(xalign=0, yalign=0.5, xscale=0, yscale=0)
self._tag_view = Gtk.TextView()
self._tag_view.set_size_request(ENTRY_WIDTH, -1)
self._tag_view.set_wrap_mode(Gtk.WrapMode.WORD)
self._tag_view.get_buffer().set_text(label)
if self._reflection.activity.initiating:
self._tag_view.connect("focus-in-event", self._tag_focus_in_cb, _("Add a #tag"))
self._tag_view.connect("focus-out-event", self._tags_focus_out_cb)
else:
self._tag_view.set_editable(False)
self._tag_align.add(self._tag_view)
self._tag_view.show()
self._grid.attach(self._tag_align, 1, row, 5, 1)
if self._reflection.activity.initiating:
self._new_tag = EventIcon(icon_name="ok", pixel_size=BUTTON_SIZE)
self._new_tag.connect("button-press-event", self._tag_button_cb)
self._grid.attach(self._new_tag, 6, row, 1, 1)
row += 1
self._activities_align = Gtk.Alignment.new(xalign=0, yalign=0.5, xscale=0, yscale=0)
self._make_activities_grid()
#.........这里部分代码省略.........